public class ReversedLinesFileReader
extends java.lang.Object
implements java.io.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(java.io.File file)
Deprecated.
Use
ReaderInputStream.builder() instead |
ReversedLinesFileReader(java.io.File file,
java.nio.charset.Charset charset)
Deprecated.
Use
ReaderInputStream.builder() instead |
ReversedLinesFileReader(java.io.File file,
int blockSize,
java.nio.charset.Charset charset)
Deprecated.
Use
ReaderInputStream.builder() instead |
ReversedLinesFileReader(java.io.File file,
int blockSize,
java.lang.String charsetName)
Deprecated.
Use
ReaderInputStream.builder() instead |
ReversedLinesFileReader(java.nio.file.Path file,
java.nio.charset.Charset charset)
Deprecated.
Use
ReaderInputStream.builder() instead |
ReversedLinesFileReader(java.nio.file.Path file,
int blockSize,
java.nio.charset.Charset charset)
Deprecated.
Use
ReaderInputStream.builder() instead |
ReversedLinesFileReader(java.nio.file.Path file,
int blockSize,
java.lang.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.
|
java.lang.String |
readLine()
Returns the lines of the file from bottom to top.
|
java.util.List<java.lang.String> |
readLines(int lineCount)
Returns
lineCount lines of the file from bottom to top. |
java.lang.String |
toString(int lineCount)
Returns the last
lineCount lines of the file. |
@Deprecated
public ReversedLinesFileReader(java.io.File file)
throws java.io.IOException
ReaderInputStream.builder() insteadfile - the file to be readjava.io.IOException - if an I/O error occurs.@Deprecated
public ReversedLinesFileReader(java.io.File file,
java.nio.charset.Charset charset)
throws java.io.IOException
ReaderInputStream.builder() insteadfile - the file to be readcharset - the charset to use, null uses the default Charset.java.io.IOException - if an I/O error occurs.@Deprecated
public ReversedLinesFileReader(java.io.File file,
int blockSize,
java.nio.charset.Charset charset)
throws java.io.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.java.io.IOException - if an I/O error occurs.@Deprecated
public ReversedLinesFileReader(java.io.File file,
int blockSize,
java.lang.String charsetName)
throws java.io.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.java.io.IOException - if an I/O error occursjava.nio.charset.UnsupportedCharsetException - thrown instead of
UnsupportedEncodingException
in version 2.2 if the
encoding is not
supported.@Deprecated
public ReversedLinesFileReader(java.nio.file.Path file,
java.nio.charset.Charset charset)
throws java.io.IOException
ReaderInputStream.builder() insteadfile - the file to be readcharset - the charset to use, null uses the default Charset.java.io.IOException - if an I/O error occurs.@Deprecated
public ReversedLinesFileReader(java.nio.file.Path file,
int blockSize,
java.nio.charset.Charset charset)
throws java.io.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.java.io.IOException - if an I/O error occurs.@Deprecated
public ReversedLinesFileReader(java.nio.file.Path file,
int blockSize,
java.lang.String charsetName)
throws java.io.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.java.io.IOException - if an I/O error occursjava.nio.charset.UnsupportedCharsetException - 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 java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException - if an I/O error occurs.public java.lang.String readLine()
throws java.io.IOException
java.io.IOException - if an I/O error occurs.public java.util.List<java.lang.String> readLines(int lineCount)
throws java.io.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.java.io.IOException - if an I/O error occurs.public java.lang.String toString(int lineCount)
throws java.io.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.java.io.IOException - if an I/O error occurs.Copyright © 2010 - 2023 Adobe. All Rights Reserved