I need to read a long text file from the bottom to the top. (ie I need to read the last line first and then the second to last line....etc) Is there any optimized code out there to do this?
Thanks,
Bebandit
Printable View
I need to read a long text file from the bottom to the top. (ie I need to read the last line first and then the second to last line....etc) Is there any optimized code out there to do this?
Thanks,
Bebandit
HOw big are the text files?
I could think of a few ways to do this... the performance of the chosen method really hinges on what else needs to be done, how big the files are...etc.
You could just you a seekable stream and keep moving back one byte a time...
You could load the contents of a text file into an array using split, then reverse the array...
a host of about 3 other options too...