? ReversedLinesFileReader
java.lang.Object
org.apache.commons.io.input.ReversedLinesFileReader
- ????????:
Closeable
,AutoCloseable
Reads lines in a file reversely (similar to a BufferedReader, but starting at
the last line). Useful for e.g. searching in log files.
- ???????:
- 2.2
-
?????
????????ReversedLinesFileReader
(File file) ????ReversedLinesFileReader
(File file, int blockSize, String charsetName) Creates a ReversedLinesFileReader with the given block size and encoding.ReversedLinesFileReader
(File file, int blockSize, Charset charset) Creates a ReversedLinesFileReader with the given block size and encoding.ReversedLinesFileReader
(File file, Charset charset) Creates a ReversedLinesFileReader with default block size of 4KB and the specified encoding.ReversedLinesFileReader
(Path file, int blockSize, String charsetName) Creates a ReversedLinesFileReader with the given block size and encoding.ReversedLinesFileReader
(Path file, int blockSize, Charset charset) Creates a ReversedLinesFileReader with the given block size and encoding.ReversedLinesFileReader
(Path file, Charset charset) Creates a ReversedLinesFileReader with default block size of 4KB and the specified encoding. -
????
-
???????
-
ReversedLinesFileReader
????2.5 useReversedLinesFileReader(File, Charset)
insteadCreates a ReversedLinesFileReader with default block size of 4KB and the platform's default encoding.- ??:
file
- the file to be read- ??:
IOException
- if an I/O error occurs.
-
ReversedLinesFileReader
Creates a ReversedLinesFileReader with default block size of 4KB and the specified encoding.- ??:
file
- the file to be readcharset
- the charset to use, null uses the default Charset.- ??:
IOException
- if an I/O error occurs.- ???????:
- 2.5
-
ReversedLinesFileReader
Creates a ReversedLinesFileReader with the given block size and encoding.- ??:
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).charset
- the encoding of the file, null uses the default Charset.- ??:
IOException
- if an I/O error occurs.- ???????:
- 2.3
-
ReversedLinesFileReader
Creates a ReversedLinesFileReader with the given block size and encoding.- ??:
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).charsetName
- the encoding of the file, null uses the default Charset.- ??:
IOException
- if an I/O error occursUnsupportedCharsetException
- thrown instead ofUnsupportedEncodingException
in version 2.2 if the encoding is not supported.
-
ReversedLinesFileReader
Creates a ReversedLinesFileReader with default block size of 4KB and the specified encoding.- ??:
file
- the file to be readcharset
- the charset to use, null uses the default Charset.- ??:
IOException
- if an I/O error occurs.- ???????:
- 2.7
-
ReversedLinesFileReader
Creates a ReversedLinesFileReader with the given block size and encoding.- ??:
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).charset
- the encoding of the file, null uses the default Charset.- ??:
IOException
- if an I/O error occurs.- ???????:
- 2.7
-
ReversedLinesFileReader
Creates a ReversedLinesFileReader with the given block size and encoding.- ??:
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).charsetName
- the encoding of the file, null uses the default Charset.- ??:
IOException
- if an I/O error occursUnsupportedCharsetException
- thrown instead ofUnsupportedEncodingException
in version 2.2 if the encoding is not supported.- ???????:
- 2.7
-
-
??????
-
close
Closes underlying resources.- ???:
close
????AutoCloseable
- ???:
close
????Closeable
- ??:
IOException
- if an I/O error occurs.
-
readLine
Returns the lines of the file from bottom to top.- ??:
- the next line or null if the start of the file is reached
- ??:
IOException
- if an I/O error occurs.
-
readLines
ReturnslineCount
lines of the file from bottom to top.If there are less than
lineCount
lines in the file, then that's what you get.Note: You can easily flip the result with
Collections.reverse(List)
.- ??:
lineCount
- How many lines to read.- ??:
- A new list
- ??:
IOException
- if an I/O error occurs.- ???????:
- 2.8.0
-
toString
Returns the lastlineCount
lines of the file.If there are less than
lineCount
lines in the file, then that's what you get.- ??:
lineCount
- How many lines to read.- ??:
- A String.
- ??:
IOException
- if an I/O error occurs.- ???????:
- 2.8.0
-
ReversedLinesFileReader(File, Charset)
instead