Reading a huge Text file(arround 10 MB) in multiple chunks.
Hi,
I want to read a huge text file(10 mb) in multiple chunks,not loading the whole file in the RAM. say for e.g.getNextChunk(int chunkSize) should give me the next chunk of words based on the varibale size passed in, and when i call the same method one more time it should move to next chunk of the same file.
it is like reading a paragaraph and moving to next paragraph. the number of words to be read will be passed in thechunkSize varible.
and this getNextChunk(int chunkSize) will be called by multiple threads,
could you please provide a solution
thanks in advance,
Sakthivel.
[663 byte] By [
Sakthivela] at [2007-11-26 16:05:28]

# 1
10 MByte is not a 'huge' text file and, unless you are talking of reading it in a server, loading it into memory as a whole is easy since it will take about 20 MByte (depending on the files character encoding) of main memory.
There is one possible problem that I can see with your approach. If the character encoding is single byte per character then no problem but if the encoding is multi-byte then you will need to deal with the case where 'chunkSize' splits a character.
This forum is not a programming service and people will help when you have a problem but they are unlikely to write the code for you. Write the code and if you have problems post the code and information about the problem.