Package org.nuiton.util
Class ReverseFileReader
java.lang.Object
org.nuiton.util.ReverseFileReader
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class ReverseFileReader
extends java.lang.Object
implements java.io.Closeable
Reverse file reader.
Read file line by line for end of file to begin of file.
- Author:
- chatellier
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Stringfilenameprotected longpositionprotected java.io.RandomAccessFilerandomfile -
Constructor Summary
Constructors Constructor Description ReverseFileReader(java.io.File file)ReverseFileReader(java.lang.String filename) -
Method Summary
-
Field Details
-
filename
protected java.lang.String filename -
randomfile
protected java.io.RandomAccessFile randomfile -
position
protected long position
-
-
Constructor Details
-
ReverseFileReader
public ReverseFileReader(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
ReverseFileReader
public ReverseFileReader(java.lang.String filename) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Details
-
readLine
public java.lang.String readLine() throws java.io.IOExceptionRead one line from the current position towards the beginning.- Returns:
- the next line of text from this file, or null if end of file is encountered before even one byte is read.
- Throws:
java.io.IOException- if any pb while reading line
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-