Why not try something like this:
BufferedReader br = new BufferedReader(new FileReader(<FileName>), int size);
Just enter the size of the buffer and continue to check yours subStringsonly in this piece. If nothing is found, drop it and go to the next snippet.
noMAD source
share