|
FlexDoc/Javadoc 2.0 Demo Java Doc |
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.
Field Summary |
Fields inherited from class java.io.FilterInputStream |
Constructor Summary |
||
Deprecated. Constructs a newline number input stream that reads its input
from the specified input stream.
|
Method Summary |
||
int |
Deprecated. Returns the number of bytes that can be read from this input
stream without blocking.
|
|
int |
Deprecated. Returns the current line number.
|
|
void |
mark(int readlimit)
Deprecated. Marks the current position in this input stream.
|
|
int |
read()
Deprecated. Reads the next byte of data from this input stream.
|
|
int |
read(byte[] b, int off, int len)
Deprecated. Reads up to len bytes of data from this input stream
into an array of bytes.
|
|
void |
reset()
Deprecated. Repositions this stream to the position at the time the
mark method was last called on this input stream.
|
|
void |
setLineNumber(int lineNumber)
Deprecated. Sets the line number to the specified argument.
|
|
long |
skip(long n)
Deprecated. Skips over and discards n bytes of data from this
input stream.
|
Methods inherited from class java.io.FilterInputStream |
Methods inherited from class java.io.InputStream |
Methods inherited from class java.lang.Object |
public LineNumberInputStream |
(InputStream in) |
public int read |
() |
throws |
The read method of LineNumberInputStream calls the read method of the underlying input stream. It checks for carriage returns and newline characters in the input, and modifies the current line number as appropriate. A carriage-return character or a carriage return followed by a newline character are both converted into a single newline character.
public int read |
(byte[] b, int off, int len) |
throws |
The read method of LineNumberInputStream repeatedly calls the read method of zero arguments to fill in the byte array.
public long skip |
(long n) |
throws |
The skip method of LineNumberInputStream creates a byte array and then repeatedly reads into it until n bytes have been read or the end of the stream has been reached.
public void setLineNumber |
(int lineNumber) |
public int getLineNumber |
() |
public int available |
() |
throws |
Note that if the underlying input stream is able to supply k input characters without blocking, the LineNumberInputStream can guarantee only to provide k/2 characters without blocking, because the k characters from the underlying input stream might consist of k/2 pairs of '\r' and '\n', which are converted to just k/2 '\n' characters.
public void mark |
(int readlimit) |
The mark method of LineNumberInputStream remembers the current line number in a private variable, and then calls the mark method of the underlying input stream.
public void reset |
() |
throws |
The reset method of LineNumberInputStream resets the line number to be the line number at the time the mark method was called, and then calls the reset method of the underlying input stream.
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.
|
FlexDoc/Javadoc 2.0 Demo Java Doc |