final class ExtendedBufferedReader
extends java.io.BufferedReader
The reader also contains a peek method, which allows you to see the next char returned by
Modifier and Type | Field and Description |
---|---|
private boolean |
closed
Whether or not this reader has been closed.
|
static int |
CR |
private long |
currentLine
The current line index.
|
private static int |
defaultGuessLineLength |
static int |
EOF |
private int |
lastReadChar
The last char returned from read() (or an overload)
Usage: If lastReadChar is CR and a LF is encountered next, the currentLine should NOT be incremented.
|
static int |
LF |
private long |
position
The position, which is number of characters read so far
|
static int |
UNKNOWN |
Constructor and Description |
---|
ExtendedBufferedReader(java.io.Reader reader)
Created extended buffered reader using default buffer-size
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the stream.
|
(package private) long |
getCurrentLineNumber()
Returns the current line number
|
(package private) int |
getLastChar()
Returns the last character that was read as an integer (0 to 65535).
|
(package private) long |
getPosition()
Gets the character position in the reader.
|
boolean |
isClosed() |
(package private) int |
peek()
Returns the next character in the current reader without consuming it.
|
int |
read() |
int |
read(char[] buf,
int offset,
int length) |
java.lang.String |
readLine()
Does not call
BufferedReader.readLine() because that method drops the line terminator(s). |
java.lang.String |
readLine(boolean dropEolChars) |
java.lang.String |
readLine(boolean dropEolChars,
int guessLineLength) |
private boolean closed
public static final int CR
private long currentLine
private static final int defaultGuessLineLength
public static final int EOF
private int lastReadChar
public static final int LF
private long position
public static final int UNKNOWN
ExtendedBufferedReader(java.io.Reader reader)
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.BufferedReader
java.io.IOException
- If an I/O error occurslong getCurrentLineNumber()
int getLastChar()
peek()
method. If no
character has been read then this will return UNKNOWN
. If the end of the stream was reached
on the last read then this will return EOF
.long getPosition()
public boolean isClosed()
int peek() throws java.io.IOException
read()
will
still return this value. Does not affect line number or last character.java.io.IOException
- if there is an error in readingpublic int read() throws java.io.IOException
read
in class java.io.BufferedReader
java.io.IOException
public int read(char[] buf, int offset, int length) throws java.io.IOException
read
in class java.io.BufferedReader
java.io.IOException
public java.lang.String readLine() throws java.io.IOException
BufferedReader.readLine()
because that method drops the line terminator(s).
Increments currentLine
Sets lastReadChar
to EOF
at EOF, otherwise to LF
readLine
in class java.io.BufferedReader
java.io.IOException
public java.lang.String readLine(boolean dropEolChars) throws java.io.IOException
java.io.IOException
public java.lang.String readLine(boolean dropEolChars, int guessLineLength) throws java.io.IOException
java.io.IOException