I'm creating an Android app which is going to read very large files, with about 1.000 to 40.000 lines, which takes quite a bit of time with a single loop. Therefore, I'm trying to create a multithreaded reader, which creates multiple threads, and each of them reads a specific part of the file, and then it puts all the small parts together in one big array or String
.
I'm using a BufferedReader
which loops through each line in the file, and store the line count.
Each time the loop run, I check if lineNumber % LINES_PER_READER == 0
is true. If it is, I create a new reader thread, which should read the next LINES_PER_THREAD
-number of lines in the file.
I wonder (because the files can be huge) if I can copy or clone the BufferedReader
in any way, so that the new reader thread can just start reading from the line where it was created, because I already have a loop which is reading that line, instead of creating a new BufferedReader
, read each line until I get to the specified line and then start reading the actual values.