I have a large text file that I need to search for a specific string. Is there a fast way to do this without reading line by line?
This method is extremely slow beca
As Wayne Cornish already said: Reading line by line might be the best approach.
If you read for instance the entire file into a string and then search with a regular expression, it might be more elegant, but you'll create a large string object.
These kind of objects might cause problems, because they will be stored on the Large Object Heap (LOH, for objects above 85.000 bytes). If you parse many of these big files and your memory is limited (x86), you are likely to run into LOH fragmentation problems.
=> Better read line by line if you parse many big files!