public class ReversedLinesFileReader extends Object implements Closeable
| Constructor and Description |
|---|
ReversedLinesFileReader(File file)
Deprecated.
2.5 use
ReversedLinesFileReader(File, Charset) instead |
ReversedLinesFileReader(File file,
Charset charset)
Creates a ReversedLinesFileReader with default block size of 4KB and the
specified encoding.
|
ReversedLinesFileReader(File file,
int blockSize,
Charset charset)
Creates a ReversedLinesFileReader with the given block size and encoding.
|
ReversedLinesFileReader(File file,
int blockSize,
String charsetName)
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(Path file,
int blockSize,
Charset charset)
Creates a ReversedLinesFileReader with the given block size and encoding.
|
ReversedLinesFileReader(Path file,
int blockSize,
String charsetName)
Creates a ReversedLinesFileReader with the given block size and encoding.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes underlying resources.
|
String |
readLine()
Returns the lines of the file from bottom to top.
|
List<String> |
readLines(int lineCount)
Returns
lineCount lines of the file from bottom to top. |
String |
toString(int lineCount)
Returns the last
lineCount lines of the file. |
@Deprecated public ReversedLinesFileReader(File file) throws IOException
ReversedLinesFileReader(File, Charset) insteadfile - the file to be readIOException - if an I/O error occurs.public ReversedLinesFileReader(File file, Charset charset) throws IOException
file - the file to be readcharset - the charset to use, null uses the default Charset.IOException - if an I/O error occurs.public ReversedLinesFileReader(File file, int blockSize, Charset charset) throws 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).charset - the encoding of the file, null uses the default Charset.IOException - if an I/O error occurs.public ReversedLinesFileReader(File file, int blockSize, String charsetName) throws 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).charsetName - the encoding of the file, null uses the default Charset.IOException - if an I/O error occursUnsupportedCharsetException - thrown instead of
UnsupportedEncodingException
in version 2.2 if the
encoding is not
supported.public ReversedLinesFileReader(Path file, Charset charset) throws IOException
file - the file to be readcharset - the charset to use, null uses the default Charset.IOException - if an I/O error occurs.public ReversedLinesFileReader(Path file, int blockSize, Charset charset) throws 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).charset - the encoding of the file, null uses the default Charset.IOException - if an I/O error occurs.public ReversedLinesFileReader(Path file, int blockSize, String charsetName) throws 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).charsetName - the encoding of the file, null uses the default Charset.IOException - if an I/O error occursUnsupportedCharsetException - thrown instead of
UnsupportedEncodingException
in version 2.2 if the
encoding is not
supported.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOException - if an I/O error occurs.public String readLine() throws IOException
IOException - if an I/O error occurs.public List<String> readLines(int lineCount) throws IOException
lineCount 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.IOException - if an I/O error occurs.public String toString(int lineCount) throws IOException
lineCount 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.IOException - if an I/O error occurs.Copyright © 2002–2021 The Apache Software Foundation. All rights reserved.