|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
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.
Fields inherited from class java.io.Reader |
lock |
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, markSupported, ready |
Methods inherited from class java.io.Reader |
read |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LineNumberReader(Reader in)
in
- a Reader object to provide the underlying stream.public LineNumberReader(Reader in, int sz)
in
- a Reader object to provide the underlying stream.sz
- an int specifying the size of the buffer.Method Detail |
public void setLineNumber(int lineNumber)
lineNumber
- an int specifying the line number.getLineNumber()
public int getLineNumber()
setLineNumber(int)
public int read() throws IOException
read
in class BufferedReader
IOException
- If an I/O error occurspublic int read(char[] cbuf, int off, int len) throws IOException
read
in class BufferedReader
cbuf
- Destination bufferoff
- Offset at which to start storing characterslen
- Maximum number of characters to readIOException
- If an I/O error occurspublic String readLine() throws IOException
readLine
in class BufferedReader
IOException
- If an I/O error occurspublic long skip(long n) throws IOException
skip
in class BufferedReader
n
- The number of characters to skipIOException
- If an I/O error occurspublic void mark(int readAheadLimit) throws IOException
mark
in class BufferedReader
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.IOException
- If an I/O error occurspublic void reset() throws IOException
reset
in class BufferedReader
IOException
- If the stream has not been marked,
or if the mark has been invalidated
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Oracle and/or its affiliates, in the US and other countries.
Copyright © 1995, 2010 Oracle and/or its affiliates. All rights reserved.