THE PACKAGE JAVA.IO
java.io.LineNumberInputStream
22.12
22.12 The Class
java.io.LineNumberInputStream
A
LineNumberInputStream
adds functionality to another input stream, namely
the ability to count lines. When the
LineNumberInputStream
is created, the line
number counter is set to zero. As bytes from the stream are read or skipped, the
counter is incremented whenever a line terminator (
\n
,
\r
, or
\r\n
) is encoun
tered. Such line terminators are also converted to a single
\n
character. The
method
getLineNumber
returns the current value of the counter, and the method
setLineNumber
sets the counter to a given integer value. If the contained input
stream supports the
mark
operation, then so does the
LineNumberInputStream
;
the
mark
operation remembers the line number counter and the
reset
operation
sets the counter to the value remembered by the
mark
operation.
public class LineNumberInputStream extends FilterInputStream {
public LineNumberInputStream(InputStream in);
public int read() throws IOException;
public int read(byte[] b)
throws IOException, NullPointerException;
public int read(byte[] b, int off, int len)
throws IOException, NullPointerException,
IndexOutOfBoundsException;
public long skip(long n) throws IOException;
public int available() throws IOException;
public void mark(int readlimit);
public void reset() throws IOException;
public int getLineNumber();
public void setLineNumber(int lineNumber);
}
22.12.1
public LineNumberInputStream(InputStream in)
This constructor initializes a newly created
LineNumberInputStream
by saving
its argument, the input stream
in
, for later use.
22.12.2
public int read() throws IOException
See the general contract of the
read
method of
InputStream
( 22.3.1).
As bytes are read from the contained input stream, line terminators are recog
nized and counted. For each line terminator recognized in the contained input
stream, a single character
\n
is returned.
Overrides the
read
method of
FilterInputStream
( 22.9.3).
707
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved