All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.io.InputStream | +----java.io.FilterInputStream
The class FilterInputStream
itself simply overrides all methods of InputStream
with versions that pass all requests to the underlying input stream. Subclasses of FilterInputStream
may further override some of these methods as well as provide additional methods and fields.
mark
and reset
methods. byte.length
bytes of data from this input stream into an array of bytes. len
bytes of data from this input stream into an array of bytes. mark
method was last called on this input stream. n
bytes of data from the input stream. protected InputStream in
protected FilterInputStream(InputStream in)
public int read() throws IOException
int
in the range 0
to 255
. If no byte is available because the end of the stream has been reached, the value -1
is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown. The read
method of FilterInputStream
calls the read
method of its underlying input stream and returns whatever value that method returns.
-1
if the end of the stream is reached. public int read(byte b[]) throws IOException
byte.length
bytes of data from this input stream into an array of bytes. This method blocks until some input is available. The read
method of FilterInputStream
calls the read
method of three arguments with the arguments b
, 0
, and b.length
, and returns whatever value that method returns.
Note that this method does not call the one-argument read
method of its underlying stream with the single argument b
. Subclasses of FilterInputStream
do not need to override this method if they have overridden the three-argument read
method.
-1
if there is no more data because the end of the stream has been reached. public int read(byte b[], int off, int len) throws IOException
len
bytes of data from this input stream into an array of bytes. This method blocks until some input is available. The read
method of FilterInputStream
calls the read
method of its underlying input stream with the same arguments and returns whatever value that method returns.
-1
if there is no more data because the end of the stream has been reached. public long skip(long n) throws IOException
n
bytes of data from the input stream. The skip
method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0
. The actual number of bytes skipped is returned. The skip
method of FilterInputStream
calls the skip
method of its underlying input stream with the same argument, and returns whatever value that method does.
public int available() throws IOException
The available
method of FilterInputStream
calls the available
method of its underlying input stream and returns whatever value that method returns.
public void close() throws IOException
close
method of FilterInputStream
calls the close
method of its underlying input stream. public synchronized void mark(int readlimit)
reset
method repositions this stream at the last marked position so that subsequent reads re-read the same bytes. The readlimit
argument tells this input stream to allow that many bytes to be read before the mark position gets invalidated.
The mark
method of FilterInputStream
calls the mark
method of its underlying input stream with the readlimit
argument.
public synchronized void reset() throws IOException
mark
method was last called on this input stream. The reset
method of FilterInputStream
calls the reset
method of its 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 parse, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails. If this happens within readlimit bytes, it allows the outer code to reset the stream and try another parser.
public boolean markSupported()
mark
and reset
methods. The markSupported
method of FilterInputStream
calls the markSupported
method of its underlying input stream and returns whatever value that method returns. true
if this stream type supports the mark
and reset
method; false
otherwise. All Packages Class Hierarchy This Package Previous Next Index