<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.io.LineNumberInputStream
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.io.html">This Package</a>  <a href="java.io.InputStreamReader.html#_top_">Previous</a>  <a href="java.io.LineNumberReader.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.io.LineNumberInputStream
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----<a href="java.io.InputStream.html#_top_">java.io.InputStream</a>
           |
           +----<a href="java.io.FilterInputStream.html#_top_">java.io.FilterInputStream</a>
                   |
                   +----java.io.LineNumberInputStream
</pre>
<hr>
<dl>
  <dt> public class <b>LineNumberInputStream</b>
  <dt> extends <a href="java.io.FilterInputStream.html#_top_">FilterInputStream</a>
</dl>
<b> Note: LineNumberInputStream is deprecated.</b>
<i>This class incorrectly assumes that bytes adequately represent
             characters.  As of JDK&nbsp;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.</i>
<p>
This class is an input stream filter that provides the added 
 functionality of keeping track of the current line number. 
 <p>
 A line is a sequence of bytes ending with a carriage return 
 character (<code>'&#92;r'</code>), a newline character 
 (<code>'&#92;n'</code>), 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.
 <p>
 The line number begins at <code>0</code>, and is incremented by 
 <code>1</code> when a <code>read</code> returns a newline character.
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.io.LineNumberReader.html#_top_">LineNumberReader</a>
</dl>
<hr>
<a name="index"></a>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#LineNumberInputStream(java.io.InputStream)"><b>LineNumberInputStream</b></a>(InputStream)
  <dd>  Constructs a newline number input stream that reads its input 
 from the specified input stream.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#available()"><b>available</b></a>()
  <dd>  Returns the number of bytes that can be read from this input 
 stream without blocking.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getLineNumber()"><b>getLineNumber</b></a>()
  <dd>  Returns the current line number.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#mark(int)"><b>mark</b></a>(int)
  <dd>  Marks the current position in this input stream.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#read()"><b>read</b></a>()
  <dd>  Reads the next byte of data from this input stream.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#read(byte[], int, int)"><b>read</b></a>(byte[], int, int)
  <dd>  Reads up to <code>len</code> bytes of data from this input stream 
 into an array of bytes.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#reset()"><b>reset</b></a>()
  <dd>  Repositions this stream to the position at the time the 
 <code>mark</code> method was last called on this input stream.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setLineNumber(int)"><b>setLineNumber</b></a>(int)
  <dd>  Sets the line number to the specified argument.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#skip(long)"><b>skip</b></a>(long)
  <dd>  Skips over and discards <code>n</code> bytes of data from the 
 input stream.
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="LineNumberInputStream"></a>
<a name="LineNumberInputStream(java.io.InputStream)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>LineNumberInputStream</b>
<pre>
 public LineNumberInputStream(<a href="java.io.InputStream.html#_top_">InputStream</a> in)
</pre>
<dl>
  <dd> Constructs a newline number input stream that reads its input 
 from the specified input stream.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> in - the underlying input stream.
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="read()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="read"><b>read</b></a>
<pre>
 public int read() throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Reads the next byte of data from this input stream. The value 
 byte is returned as an <code>int</code> in the range 
 <code>0</code> to <code>255</code>. If no byte is available 
 because the end of the stream has been reached, the value 
 <code>-1</code> is returned. This method blocks until input data 
 is available, the end of the stream is detected, or an exception 
 is thrown. 
 <p>
 The <code>read</code> method of 
 <code>LineNumberInputStream</code> calls the <code>read</code> 
 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.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the next byte of data, or <code>-1</code> if the end of this
             stream is reached.
    <dt> <b>Throws:</b> <a href="java.io.IOException.html#_top_">IOException</a>
    <dd> if an I/O error occurs.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.io.FilterInputStream.html#read()">read</a> in class <a href="java.io.FilterInputStream.html#_top_">FilterInputStream</a>
    <dt> <b>See Also:</b>
    <dd> <a href="java.io.FilterInputStream.html#in">in</a>, <a href="#getLineNumber()">getLineNumber</a>
  </dl></dd>
</dl>
<a name="read(byte[], int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="read"><b>read</b></a>
<pre>
 public int read(byte b[],
                 int off,
                 int len) throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Reads up to <code>len</code> bytes of data from this input stream 
 into an array of bytes. This method blocks until some input is available.
 <p>
 The <code>read</code> method of 
 <code>LineNumberInputStream</code> repeatedly calls the 
 <code>read</code> method of zero arguments to fill in the byte array.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> b - the buffer into which the data is read.
    <dd> off - the start offset of the data.
    <dd> len - the maximum number of bytes read.
    <dt> <b>Returns:</b>
    <dd> the total number of bytes read into the buffer, or
             <code>-1</code> if there is no more data because the end of
             this stream has been reached.
    <dt> <b>Throws:</b> <a href="java.io.IOException.html#_top_">IOException</a>
    <dd> if an I/O error occurs.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.io.FilterInputStream.html#read(byte[], int, int)">read</a> in class <a href="java.io.FilterInputStream.html#_top_">FilterInputStream</a>
    <dt> <b>See Also:</b>
    <dd> <a href="#read()">read</a>
  </dl></dd>
</dl>
<a name="setLineNumber(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setLineNumber"><b>setLineNumber</b></a>
<pre>
 public void setLineNumber(int lineNumber)
</pre>
<dl>
  <dd> Sets the line number to the specified argument.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> lineNumber - the new line number.
  </dl></dd>
</dl>
<a name="getLineNumber()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getLineNumber"><b>getLineNumber</b></a>
<pre>
 public int getLineNumber()
</pre>
<dl>
  <dd> Returns the current line number.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the current line number.
  </dl></dd>
</dl>
<a name="skip(long)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="skip"><b>skip</b></a>
<pre>
 public long skip(long n) throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Skips over and discards <code>n</code> bytes of data from the 
 input stream. The <code>skip</code> method may, for a variety of 
 reasons, end up skipping over some smaller number of bytes, 
 possibly <code>0</code>. The actual number of bytes skipped is returned.
 <p>
 The <code>skip</code> method of 
 <code>LineNumberInputStream</code> creates a byte array of length 
 <code>n</code> and then reads into it until <code>n</code> bytes 
 have been read or the end of the stream has been reached.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> n - the number of bytes to be skipped.
    <dt> <b>Returns:</b>
    <dd> the actual number of bytes skipped.
    <dt> <b>Throws:</b> <a href="java.io.IOException.html#_top_">IOException</a>
    <dd> if an I/O error occurs.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.io.FilterInputStream.html#skip(long)">skip</a> in class <a href="java.io.FilterInputStream.html#_top_">FilterInputStream</a>
  </dl></dd>
</dl>
<a name="available()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="available"><b>available</b></a>
<pre>
 public int available() throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Returns the number of bytes that can be read from this input 
 stream without blocking. 
 <p>
 Note that if the underlying input stream is able to supply 
 <i>k</i> input characters without blocking, the 
 <code>LineNumberInputStream</code> can guarantee only to provide 
 <i>k</i>/2 characters without blocking, because the 
 <i>k</i> characters from the underlyhing input stream might 
 consist of <i>k</i>/2 pairs of <code>'&#92;r'</code> and 
 <code>'&#92;n'</code>, which are converted to just 
 <i>k</i>/2 <code>'&#92;n'</code> characters.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the number of bytes that can be read from this input stream
             without blocking.
    <dt> <b>Throws:</b> <a href="java.io.IOException.html#_top_">IOException</a>
    <dd> if an I/O error occurs.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.io.FilterInputStream.html#available()">available</a> in class <a href="java.io.FilterInputStream.html#_top_">FilterInputStream</a>
    <dt> <b>See Also:</b>
    <dd> <a href="java.io.FilterInputStream.html#in">in</a>
  </dl></dd>
</dl>
<a name="mark(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="mark"><b>mark</b></a>
<pre>
 public void mark(int readlimit)
</pre>
<dl>
  <dd> Marks the current position in this input stream. A subsequent 
 call to the <code>reset</code> method repositions this stream at 
 the last marked position so that subsequent reads re-read the same bytes.
 <p>
 The <code>mark</code> method of 
 <code>LineNumberInputStream</code> remembers the current line 
 number in a private variable, and then calls the <code>mark</code> 
 method of the underlying input stream.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> readlimit - the maximum limit of bytes that can be read before
                      the mark position becomes invalid.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.io.FilterInputStream.html#mark(int)">mark</a> in class <a href="java.io.FilterInputStream.html#_top_">FilterInputStream</a>
    <dt> <b>See Also:</b>
    <dd> <a href="java.io.FilterInputStream.html#in">in</a>, <a href="#reset()">reset</a>
  </dl></dd>
</dl>
<a name="reset()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="reset"><b>reset</b></a>
<pre>
 public void reset() throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Repositions this stream to the position at the time the 
 <code>mark</code> method was last called on this input stream. 
 <p>
 The <code>reset</code> method of 
 <code>LineNumberInputStream</code> resets the line number to be 
 the line number at the time the <code>mark</code> method was 
 called, and then calls the <code>reset</code> method of the 
 underlying input stream. 
 <p>
 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.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.io.IOException.html#_top_">IOException</a>
    <dd> if an I/O error occurs.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.io.FilterInputStream.html#reset()">reset</a> in class <a href="java.io.FilterInputStream.html#_top_">FilterInputStream</a>
    <dt> <b>See Also:</b>
    <dd> <a href="java.io.FilterInputStream.html#in">in</a>, <a href="#mark(int)">mark</a>
  </dl></dd>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.io.html">This Package</a>  <a href="java.io.InputStreamReader.html#_top_">Previous</a>  <a href="java.io.LineNumberReader.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
