public class LineBufferedReader
extends java.io.Reader
Modifier and Type | Field and Description |
---|---|
char[] |
buffer
The input buffer, containing the current line etc.
|
static int |
BUFFER_SIZE
Default (initial buffer) size.
|
protected java.io.Reader |
in |
int |
limit
The length of the valid (data-containing) part of the buffer.
|
protected int |
lineNumber
The current line number (at position of lineStartPos).
|
protected int |
markPos
The position of the mark (assuming
readAheadLinit > 0 ). |
int |
pos
The current read position, as an index into buffer.
|
protected int |
readAheadLimit
If mark has been called, and not invalidated, the read ahead limit.
|
char |
readState |
Constructor and Description |
---|
LineBufferedReader(java.io.InputStream in) |
LineBufferedReader(java.io.Reader in) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected int |
fill(int len)
Called by
read() when it needs its buffer filled. |
int |
getColumnNumber()
Return the current (zero-based) column number.
|
boolean |
getConvertCR()
True if CR and CRLF should be converted to LF.
|
int |
getLineNumber()
Get the current line number.
|
java.lang.String |
getName() |
Path |
getPath() |
char |
getReadState()
Return a character that indicates what we are currently reading.
|
void |
incrLineNumber(int lineDelta,
int lineStartPos) |
boolean |
isOpen() |
void |
lineStart(boolean revisited)
A hook to allow sub-classes to perform some action at start of line.
|
void |
mark(int readAheadLimit) |
boolean |
markSupported() |
int |
peek() |
int |
peekCodePoint() |
static int |
peekCodePoint(java.io.Reader in) |
int |
read() |
int |
read(char[] cbuf,
int off,
int len) |
int |
readCodePoint() |
static int |
readCodePoint(java.io.Reader in)
Reads a Unicode character (codepoint) by checking for surrogates.
|
java.lang.String |
readLine() |
void |
readLine(java.lang.StringBuffer sbuf,
char mode)
Read a line.
|
boolean |
ready() |
void |
reset() |
void |
setBuffer(char[] buffer)
Specify a buffer to use for the input buffer.
|
void |
setConvertCR(boolean convertCR) |
void |
setKeepFullLines(boolean keep)
Should we preserve the complete current line?
The default is true, but in some cases there can be a performance
improvement if we don't need to keep a long line when filling the buffer.
|
void |
setLineNumber(int lineNumber) |
void |
setName(java.lang.Object name) |
void |
setPath(Path path) |
void |
skip_quick()
Same as skip(), but assumes previous command was a non-EOF peek().
|
void |
skip() |
int |
skip(int n)
Skip forwards or backwards a number of characters.
|
void |
skipRestOfLine()
Skips the rest of the current line, including the line terminator.
|
protected boolean |
sourceReady() |
void |
unread_quick()
Same as unread, but only allowed after non-EOF-returning read().
|
void |
unread() |
protected java.io.Reader in
public static final int BUFFER_SIZE
public char[] buffer
public int pos
public int limit
public char readState
protected int lineNumber
protected int readAheadLimit
protected int markPos
readAheadLinit > 0
).
(Garbage if readAheadLimit <= 0
).public LineBufferedReader(java.io.InputStream in)
public LineBufferedReader(java.io.Reader in)
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Reader
java.io.IOException
public boolean isOpen()
public char getReadState()
public void setKeepFullLines(boolean keep)
public final boolean getConvertCR()
public final void setConvertCR(boolean convertCR)
public void lineStart(boolean revisited) throws java.io.IOException
revisited
- true if we have read here before (i.e.
we did a reset or unread() to get here)java.io.IOException
protected int fill(int len) throws java.io.IOException
read()
when it needs its buffer filled.
Read characters into buffer, starting at pos, for len.
Can assume that len > 0
. Only called if pos>=limit
.
Return -1 if EOF, otherwise number of read chars.
This can be usefully overridden by sub-classes.java.io.IOException
public void setBuffer(char[] buffer) throws java.io.IOException
java.io.IOException
public int read() throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
public int read(char[] cbuf, int off, int len) throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
public Path getPath()
public void setPath(Path path)
public java.lang.String getName()
public void setName(java.lang.Object name)
public int getLineNumber()
public void setLineNumber(int lineNumber)
public void incrLineNumber(int lineDelta, int lineStartPos)
public int getColumnNumber()
public boolean markSupported()
markSupported
in class java.io.Reader
public void mark(int readAheadLimit)
mark
in class java.io.Reader
public void reset() throws java.io.IOException
reset
in class java.io.Reader
java.io.IOException
public void readLine(java.lang.StringBuffer sbuf, char mode) throws java.io.IOException
java.io.IOException
public java.lang.String readLine() throws java.io.IOException
java.io.IOException
public int skip(int n) throws java.io.IOException
java.io.IOException
public boolean ready() throws java.io.IOException
ready
in class java.io.Reader
java.io.IOException
protected boolean sourceReady() throws java.io.IOException
java.io.IOException
public final void skip_quick() throws java.io.IOException
java.io.IOException
public void skip() throws java.io.IOException
java.io.IOException
public void skipRestOfLine() throws java.io.IOException
java.io.IOException
public void unread() throws java.io.IOException
java.io.IOException
public void unread_quick()
public int peek() throws java.io.IOException
java.io.IOException
public static int readCodePoint(java.io.Reader in) throws java.io.IOException
java.io.IOException
public int readCodePoint() throws java.io.IOException
java.io.IOException
public static int peekCodePoint(java.io.Reader in) throws java.io.IOException
java.io.IOException
public int peekCodePoint() throws java.io.IOException
java.io.IOException