Deprecated
This class incorrectly assumes that bytes adequately represent characters. As of JDK 1.1, the preferred way to operate on character streams is via the new character-stream classes, which include a class for counting line numbers.
A line is a sequence of bytes ending with a carriage return
character ('\r'
), a newline character
('\n'
), or a carriage return character followed
immediately by a linefeed character. In all three cases, the line
terminating character(s) are returned as a single newline character.
The line number begins at 0
, and is incremented by
1
when a read
returns a newline character.
java.io.LineNumberReader
Modifier and Type | Field and Description |
---|---|
pack-priv int | |
pack-priv int | |
pack-priv int | |
pack-priv int |
Access | Constructor and Description |
---|---|
public | LineNumberInputStream(InputStream
the underlying input stream. in)Constructs a newline number input stream that reads its input from the specified input stream. |
Modifier and Type | Method and Description |
---|---|
public int | Returns: the number of bytes that can be read from this input stream without blocking.Overrides java. Returns the number of bytes that can be read from this input stream without blocking. |
public int | |
public void | mark(int
the maximum limit of bytes that can be read before
the mark position becomes invalid. readlimit)Overrides java. Marks the current position in this input stream. |
public int | Returns: the next byte of data, or-1 if the end of this
stream is reached.Overrides java. Reads the next byte of data from this input stream. |
public int | Returns: the total number of bytes read into the buffer, or-1 if there is no more data because the end of
this stream has been reached.the buffer into which the data is read. b, int the start offset of the data. off, int the maximum number of bytes read. len)Overrides java. Reads up to |
public void | reset()
Overrides java. Repositions this stream to the position at the time the
|
public void | |
public long | Returns: the actual number of bytes skipped.the number of bytes to be skipped. n)Overrides java. Skips over and discards |
lineNumber | back to summary |
---|---|
pack-priv int lineNumber |
markLineNumber | back to summary |
---|---|
pack-priv int markLineNumber |
markPushBack | back to summary |
---|---|
pack-priv int markPushBack |
pushBack | back to summary |
---|---|
pack-priv int pushBack |
LineNumberInputStream | back to summary |
---|---|
public LineNumberInputStream(InputStream in) Constructs a newline number input stream that reads its input from the specified input stream.
|
available | back to summary |
---|---|
public int available() throws IOException Overrides java. Returns the number of bytes that can be read from this input stream without blocking.
Note that if the underlying input stream is able to supply
k input characters without blocking, the
|
getLineNumber | back to summary |
---|---|
public int getLineNumber() Returns the current line number.
|
mark | back to summary |
---|---|
public void mark(int readlimit) Overrides java. Marks the current position in this input stream. A subsequent
call to the
The
|
read | back to summary |
---|---|
public int read() throws IOException Overrides java. Reads the next byte of data from this input stream. The value
byte is returned as an
The
|
read | back to summary |
---|---|
public int read(byte[] b, int off, int len) throws IOException Overrides java. Reads up to
The
|
reset | back to summary |
---|---|
public void reset() throws IOException Overrides java. Repositions this stream to the position at the time the
The Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the parser, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails, which, if it happens within readlimit bytes, allows the outer code to reset the stream and try another parser.
|
setLineNumber | back to summary |
---|---|
public void setLineNumber(int lineNumber) Sets the line number to the specified argument.
|
skip | back to summary |
---|---|
public long skip(long n) throws IOException Overrides java. Skips over and discards
The
|