final class ExtendedBufferedReader
extends java.io.BufferedReader
In particular the reader supports a look-ahead option, which allows you to see the next char returned by
read(). This reader also tracks how many characters have been read with getPosition().
| Modifier and Type | Field and Description |
|---|---|
private boolean |
closed |
private long |
eolCounter
The count of EOLs (CR/LF/CRLF) seen so far
|
private int |
lastChar
The last char returned
|
private long |
position
The position, which is number of characters read so far
|
| 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 |
lookAhead()
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()
Calls
BufferedReader.readLine() which drops the line terminator(s). |
private int lastChar
private long eolCounter
private long position
private boolean closed
ExtendedBufferedReader(java.io.Reader reader)
public int read()
throws java.io.IOException
read in class java.io.BufferedReaderjava.io.IOExceptionint getLastChar()
lookAhead() method. If no
character has been read then this will return Constants.UNDEFINED. If the end of the stream was reached
on the last read then this will return Constants.END_OF_STREAM.public int read(char[] buf,
int offset,
int length)
throws java.io.IOException
read in class java.io.BufferedReaderjava.io.IOExceptionpublic java.lang.String readLine()
throws java.io.IOException
BufferedReader.readLine() which drops the line terminator(s). This method should only be called
when processing a comment, otherwise information can be lost.
Increments eolCounter
Sets lastChar to Constants.END_OF_STREAM at EOF, otherwise to LF
readLine in class java.io.BufferedReaderjava.io.IOExceptionint lookAhead()
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 readinglong getCurrentLineNumber()
long getPosition()
public boolean isClosed()
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.BufferedReaderjava.io.IOException - If an I/O error occurs