|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.Reader | +--java.io.BufferedReader | +--java.io.LineNumberReader
A buffered character-input stream that keeps track of line numbers. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.
Field Summary | |
private int |
lineNumber
The current line number |
private int |
markedLineNumber
The line number of the mark, if any |
private boolean |
markedSkipLF
The skipLF flag when the mark was set |
private static int |
maxSkipBufferSize
Maximum skip-buffer size |
private char[] |
skipBuffer
Skip buffer, null until allocated |
private boolean |
skipLF
If the next character is a line feed, skip it |
Fields inherited from class java.io.BufferedReader |
cb,
defaultCharBufferSize,
defaultExpectedLineLength,
in,
INVALIDATED,
markedChar,
nChars,
nextChar,
readAheadLimit,
UNMARKED |
Fields inherited from class java.io.Reader |
lock,
maxSkipBufferSize,
skipBuffer |
Constructor Summary | |
LineNumberReader(Reader in)
Create a new line-numbering reader, using the default input-buffer size. |
|
LineNumberReader(Reader in,
int sz)
Create a new line-numbering reader, reading characters into a buffer of the given size. |
Method Summary | |
int |
getLineNumber()
Get the current line number. |
void |
mark(int readAheadLimit)
Mark the present position in the stream. |
int |
read()
Read a single character. |
int |
read(char[] cbuf,
int off,
int len)
Read characters into a portion of an array. |
String |
readLine()
Read a line of text. |
void |
reset()
Reset the stream to the most recent mark. |
void |
setLineNumber(int lineNumber)
Set the current line number. |
long |
skip(long n)
Skip characters. |
Methods inherited from class java.io.BufferedReader |
close,
ensureOpen,
fill,
markSupported,
read1,
readLine,
ready |
Methods inherited from class java.io.Reader |
read |
Methods inherited from class java.lang.Object |
|
Field Detail |
private int lineNumber
private int markedLineNumber
private boolean skipLF
private boolean markedSkipLF
private static final int maxSkipBufferSize
private char[] skipBuffer
Constructor Detail |
public LineNumberReader(Reader in)
public LineNumberReader(Reader in, int sz)
Method Detail |
public void setLineNumber(int lineNumber)
public int getLineNumber()
public int read() throws IOException
public int read(char[] cbuf, int off, int len) throws IOException
cbuf
- Destination bufferoff
- Offset at which to start storing characterslen
- Maximum number of characters to readpublic String readLine() throws IOException
public long skip(long n) throws IOException
n
- The number of characters to skippublic void mark(int readAheadLimit) throws IOException
readAheadLimit
- Limit on the number of characters that may be
read while still preserving the mark. After
reading this many characters, attempting to
reset the stream may fail.public void reset() throws IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |