|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.io.input.ReversedLinesFileReader
public class ReversedLinesFileReader
Reads lines in a file reversely (similar to a BufferedReader, but starting at the last line). Useful for e.g. searching in log files.
Nested Class Summary | |
---|---|
private class |
ReversedLinesFileReader.FilePart
|
Field Summary | |
---|---|
private int |
avoidNewlineSplitBufferSize
|
private int |
blockSize
|
private int |
byteDecrement
|
private ReversedLinesFileReader.FilePart |
currentFilePart
|
private java.nio.charset.Charset |
encoding
|
private byte[][] |
newLineSequences
|
private java.io.RandomAccessFile |
randomAccessFile
|
private long |
totalBlockCount
|
private long |
totalByteLength
|
private boolean |
trailingNewlineOfFileSkipped
|
Constructor Summary | |
---|---|
ReversedLinesFileReader(java.io.File file)
Creates a ReversedLinesFileReader with default block size of 4KB and the platform's default encoding. |
|
ReversedLinesFileReader(java.io.File file,
int blockSize,
java.nio.charset.Charset encoding)
Creates a ReversedLinesFileReader with the given block size and encoding. |
|
ReversedLinesFileReader(java.io.File file,
int blockSize,
java.lang.String encoding)
Creates a ReversedLinesFileReader with the given block size and encoding. |
Method Summary | |
---|---|
void |
close()
Closes underlying resources. |
java.lang.String |
readLine()
Returns the lines of the file from bottom to top. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final int blockSize
private final java.nio.charset.Charset encoding
private final java.io.RandomAccessFile randomAccessFile
private final long totalByteLength
private final long totalBlockCount
private final byte[][] newLineSequences
private final int avoidNewlineSplitBufferSize
private final int byteDecrement
private ReversedLinesFileReader.FilePart currentFilePart
private boolean trailingNewlineOfFileSkipped
Constructor Detail |
---|
public ReversedLinesFileReader(java.io.File file) throws java.io.IOException
file
- the file to be read
java.io.IOException
- if an I/O error occurspublic ReversedLinesFileReader(java.io.File file, int blockSize, java.nio.charset.Charset encoding) throws java.io.IOException
file
- the file to be readblockSize
- size of the internal buffer (for ideal performance this should
match with the block size of the underlying file system).encoding
- the encoding of the file
java.io.IOException
- if an I/O error occurspublic ReversedLinesFileReader(java.io.File file, int blockSize, java.lang.String encoding) throws java.io.IOException
file
- the file to be readblockSize
- size of the internal buffer (for ideal performance this should
match with the block size of the underlying file system).encoding
- the encoding of the file
java.io.IOException
- if an I/O error occurs
java.nio.charset.UnsupportedCharsetException
- thrown instead of UnsupportedEncodingException
in version 2.2 if the encoding is not
supported.Method Detail |
---|
public java.lang.String readLine() throws java.io.IOException
java.io.IOException
- if an I/O error occurspublic void close() throws java.io.IOException
close
in interface java.io.Closeable
java.io.IOException
- if an I/O error occurs
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |