<!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.BufferedInputStream
</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="Package-java.io.html">Previous</a>  <a href="java.io.BufferedOutputStream.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.io.BufferedInputStream
</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.BufferedInputStream
</pre>
<hr>
<dl>
  <dt> public class <b>BufferedInputStream</b>
  <dt> extends <a href="java.io.FilterInputStream.html#_top_">FilterInputStream</a>
</dl>
The class implements a buffered input stream. By setting up such 
 an input stream, an application can read bytes from a stream 
 without necessarily causing a call to the underlying system for 
 each byte read. The data is read by blocks into a buffer; 
 subsequent reads can access the data directly from the buffer.
<p>
<hr>
<a name="index"></a>
<h2>
  <img src="images/variable-index.gif" width=207 height=38 alt="Variable Index">
</h2>
<dl>
  <dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#buf"><b>buf</b></a>
  <dd>  The buffer where data is stored.
  <dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#count"><b>count</b></a>
  <dd>  The index one greater than the index of the last valid byte in 
 the buffer.
  <dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#marklimit"><b>marklimit</b></a>
  <dd>  The maximum read ahead allowed after a call to the 
 <code>mark</code> method before subsequent calls to the 
 <code>reset</code> method fail.
  <dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#markpos"><b>markpos</b></a>
  <dd>  The value of the <code>pos</code> field at the time the last 
 <code>mark</code> method was called.
  <dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#pos"><b>pos</b></a>
  <dd>  The current position in the buffer.
</dl>
<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="#BufferedInputStream(java.io.InputStream)"><b>BufferedInputStream</b></a>(InputStream)
  <dd>  Creates a new buffered input stream to read data from the 
 specified input stream with a default 512-byte buffer size.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#BufferedInputStream(java.io.InputStream, int)"><b>BufferedInputStream</b></a>(InputStream, int)
  <dd>  Creates a new buffered input stream to read data from the 
 specified input stream with the specified buffer size.
</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="#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="#markSupported()"><b>markSupported</b></a>()
  <dd>  Tests if this input stream supports the <code>mark</code> 
 and <code>reset</code> methods.
  <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 buffered 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 bytes into a portion of an array.
  <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="#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="variables"></a>
<h2>
  <img src="images/variables.gif" width=153 height=38 alt="Variables">
</h2>
<a name="buf"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>buf</b>
<pre>
 protected byte buf[]
</pre>
<dl>
  <dd> The buffer where data is stored.<p>
</dl>
<a name="count"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>count</b>
<pre>
 protected int count
</pre>
<dl>
  <dd> The index one greater than the index of the last valid byte in 
 the buffer.<p>
</dl>
<a name="pos"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>pos</b>
<pre>
 protected int pos
</pre>
<dl>
  <dd> The current position in the buffer. This is the index of the next 
 character to be read from the <code>buf</code> array.<p>
  <dd><dl> 
    <dt> <b>See Also:</b>
    <dd> <a href="#buf">buf</a>
  </dl></dd>
</dl>
<a name="markpos"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>markpos</b>
<pre>
 protected int markpos
</pre>
<dl>
  <dd> The value of the <code>pos</code> field at the time the last 
 <code>mark</code> method was called. The value of this field is 
 <code>-1</code> if there is no current mark.<p>
  <dd><dl> 
    <dt> <b>See Also:</b>
    <dd> <a href="#mark(int)">mark</a>, <a href="#pos">pos</a>
  </dl></dd>
</dl>
<a name="marklimit"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>marklimit</b>
<pre>
 protected int marklimit
</pre>
<dl>
  <dd> The maximum read ahead allowed after a call to the 
 <code>mark</code> method before subsequent calls to the 
 <code>reset</code> method fail.<p>
  <dd><dl> 
    <dt> <b>See Also:</b>
    <dd> <a href="#mark(int)">mark</a>, <a href="#reset()">reset</a>
  </dl></dd>
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="BufferedInputStream"></a>
<a name="BufferedInputStream(java.io.InputStream)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>BufferedInputStream</b>
<pre>
 public BufferedInputStream(<a href="java.io.InputStream.html#_top_">InputStream</a> in)
</pre>
<dl>
  <dd> Creates a new buffered input stream to read data from the 
 specified input stream with a default 512-byte buffer size.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> in - the underlying input stream.
  </dl></dd>
</dl>
<a name="BufferedInputStream(java.io.InputStream, int)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>BufferedInputStream</b>
<pre>
 public BufferedInputStream(<a href="java.io.InputStream.html#_top_">InputStream</a> in,
                            int size)
</pre>
<dl>
  <dd> Creates a new buffered input stream to read data from the 
 specified input stream with the specified buffer size.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> in - the underlying input stream.
    <dd> size - the buffer size.
  </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 synchronized int read() throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Reads the next byte of data from this buffered 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>BufferedInputStream</code> 
 returns the next byte of data from its buffer if the buffer is not 
 empty. Otherwise, it refills the buffer from the underlying input 
 stream and returns the next character, if the underlying stream 
 has not returned an end-of-stream indicator.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the next byte of data, or <code>-1</code> if the end of the
             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>
  </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 synchronized int read(byte b[],
                              int off,
                              int len) throws <a href="java.io.IOException.html#_top_">IOException</a>
</pre>
<dl>
  <dd> Reads bytes into a portion of an array.  This method will block until
 some input is available, an I/O error occurs, or the end of the stream
 is reached.
 <p> If this stream's buffer is not empty, bytes are copied from it into
 the array argument.  Otherwise, the buffer is refilled from the
 underlying input stream and, unless the stream returns an end-of-stream
 indication, the array argument is filled with characters from the
 newly-filled buffer.
 <p> As an optimization, if the buffer is empty, the mark is not valid,
 and <code>len</code> is at least as large as the buffer, then this
 method will read directly from the underlying stream into the given
 array.  Thus redundant <code>BufferedInputStream</code>s will not copy
 data unnecessarily.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> b - destination buffer.
    <dd> off - offset at which to start storing bytes.
    <dd> len - maximum number of bytes to read.
    <dt> <b>Returns:</b>
    <dd> the number of bytes read, or <code>-1</code> if the end of
             the 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>
  </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 synchronized 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 zero. The actual number of bytes skipped is returned. 
 <p>
 The <code>skip</code> method of <code>BufferedInputStream</code> 
 compares the number of bytes it has available in its buffer, 
 <i>k</i>, where <i>k</i>&nbsp;= <code>count&nbsp;- pos</code>, 
 with <code>n</code>. If <code>n</code>&nbsp;&le;&nbsp;<i>k</i>, 
 then the <code>pos</code> field is incremented by <code>n</code>. 
 Otherwise, the <code>pos</code> field is incremented to have the 
 value <code>count</code>, and the remaining bytes are skipped by 
 calling the <code>skip</code> method on the underlying input 
 stream, supplying the argument <code>n&nbsp;-</code>&nbsp;<i>k</i>.
<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 synchronized 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>
 The <code>available</code> method of 
 <code>BufferedInputStream</code> returns the sum of the the number 
 of bytes remaining to be read in the buffer 
 (<code>count&nbsp;- pos</code>) 
 and the result of calling the <code>available</code> method of the 
 underlying input stream.
<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 synchronized 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 the stream at 
 the last marked position so that subsequent reads re-read the same 
 bytes. 
 <p>
 The <code>readlimit</code> argument tells the input stream to 
 allow that many bytes to be read before the mark position gets 
 invalidated.
<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="#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 synchronized 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>
 If the stream has not been marked, or if the mark has been invalidated,
 an IOException is thrown. 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. If an
 exception gets tossed within readlimit bytes, the parser will allow the
 outer code to reset the stream and to try another parser.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.io.IOException.html#_top_">IOException</a>
    <dd> if this stream has not been marked or
               if the mark has been invalidated.
    <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="#mark(int)">mark</a>
  </dl></dd>
</dl>
<a name="markSupported()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="markSupported"><b>markSupported</b></a>
<pre>
 public boolean markSupported()
</pre>
<dl>
  <dd> Tests if this input stream supports the <code>mark</code> 
 and <code>reset</code> methods. The <code>markSupported</code> 
 method of <code>BufferedInputStream</code> returns 
 <code>true</code>.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> a <code>boolean</code> indicating if this stream type supports
          the <code>mark</code> and <code>reset</code> methods.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.io.FilterInputStream.html#markSupported()">markSupported</a> in class <a href="java.io.FilterInputStream.html#_top_">FilterInputStream</a>
    <dt> <b>See Also:</b>
    <dd> <a href="java.io.InputStream.html#mark(int)">mark</a>, <a href="java.io.InputStream.html#reset()">reset</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="Package-java.io.html">Previous</a>  <a href="java.io.BufferedOutputStream.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
