public class ReversedLinesFileReader extends Object implements Closeable
To build an instance, see ReversedLinesFileReader.Builder.
| Modifier and Type | Class and Description |
|---|---|
static class |
ReversedLinesFileReader.Builder
Builds a new
ReversedLinesFileReader instance. |
| Constructor and Description |
|---|
ReversedLinesFileReader(File file)
Deprecated.
Use
ReaderInputStream.builder() instead |
ReversedLinesFileReader(File file,
Charset charset)
Deprecated.
Use
ReaderInputStream.builder() instead |
ReversedLinesFileReader(File file,
int blockSize,
Charset charset)
Deprecated.
Use
ReaderInputStream.builder() instead |
ReversedLinesFileReader(File file,
int blockSize,
String charsetName)
Deprecated.
Use
ReaderInputStream.builder() instead |
ReversedLinesFileReader(Path file,
Charset charset)
Deprecated.
Use
ReaderInputStream.builder() instead |
ReversedLinesFileReader(Path file,
int blockSize,
Charset charset)
Deprecated.
Use
ReaderInputStream.builder() instead |
ReversedLinesFileReader(Path file,
int blockSize,
String charsetName)
Deprecated.
Use
ReaderInputStream.builder() instead |
| Modifier and Type | Method and Description |
|---|---|
static ReversedLinesFileReader.Builder |
builder()
Constructs a new
ReversedLinesFileReader.Builder. |
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
ReaderInputStream.builder() insteadfile - the file to be readIOException - if an I/O error occurs.@Deprecated public ReversedLinesFileReader(File file, Charset charset) throws IOException
ReaderInputStream.builder() insteadfile - the file to be readcharset - the charset to use, null uses the default Charset.IOException - if an I/O error occurs.@Deprecated public ReversedLinesFileReader(File file, int blockSize, Charset charset) throws IOException
ReaderInputStream.builder() insteadfile - 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.@Deprecated public ReversedLinesFileReader(File file, int blockSize, String charsetName) throws IOException
ReaderInputStream.builder() insteadfile - 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.@Deprecated public ReversedLinesFileReader(Path file, Charset charset) throws IOException
ReaderInputStream.builder() insteadfile - the file to be readcharset - the charset to use, null uses the default Charset.IOException - if an I/O error occurs.@Deprecated public ReversedLinesFileReader(Path file, int blockSize, Charset charset) throws IOException
ReaderInputStream.builder() insteadfile - 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.@Deprecated public ReversedLinesFileReader(Path file, int blockSize, String charsetName) throws IOException
ReaderInputStream.builder() insteadfile - 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 static ReversedLinesFileReader.Builder builder()
ReversedLinesFileReader.Builder.ReversedLinesFileReader.Builder.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–2023 The Apache Software Foundation. All rights reserved.