commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (Resolved) (JIRA)" <>
Subject [jira] [Resolved] (IO-288) Supply a ReversedLinesFileReader
Date Wed, 16 Nov 2011 01:34:51 GMT


Sebb resolved IO-288.

    Resolution: Fixed

Thanks for your perserverance!

I had problems with committing the .txt files, as SVN tried to add SVN eol-style:native. This
would have broken the tests, so they were renamed as .bin and stored as application/octet-stream.

Made some minor code changes:
- more final fields
- added extra BufferedReader comparison tests
> Supply a ReversedLinesFileReader 
> ---------------------------------
>                 Key: IO-288
>                 URL:
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Utilities
>            Reporter: Georg Henzler
>             Fix For: 2.2
>         Attachments:
> I needed to analyse a log file today and I was looking for a ReversedLinesFileReader:
A class that behaves exactly like BufferedReader except that it goes from bottom to top when
readLine() is called. I didn't find it in IOUtils and the internet didn't help a lot either,
e.g. is a fairly inefficient
- the log files I'm analysing are huge and it is not a good idea to load the whole content
in the memory. 
> So I ended up writing an implementation myself using little memory and the class RandomAccessFile
- see attached file. It's used as follows:
> int blockSize = 4096; // only that much memory is needed, no matter how big the file
> ReversedLinesFileReader reversedLinesFileReader = new ReversedLinesFileReader (myFile,
blockSize, "UTF-8"); // encoding is supported
> String line = null;
> while((line=reversedLinesFileReader.readLine())!=null) {
>   ... // use the line
>   if(enoughLinesSeen) {
>      break;  
>   }
> }
> reversedLinesFileReader.close();
> I believe this could be useful for other people as well!

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message