Packages  This Package  Prev  Next  Index  

§2.11 Class FilterInputStream

public  class  java.io.FilterInputStream
    extends  java.io.InputStream  (I-§2.13)
{
        // Fields
    protected InputStream in;	§2.11.1

        // Constructors
    protected FilterInputStream(InputStream  in);	§2.11.2

// Methods public int available(); §2.11.3 public void close(); §2.11.4 public void mark(int readlimit); §2.11.5 public boolean markSupported(); §2.11.6 public int read(); §2.11.7 public int read(byte b[]); §2.11.8 public int read(byte b[], int off, int len); §2.11.9 public void reset(); §2.11.10 public long skip(long n); §2.11.11 }
This class is the superclass of all classes that filter input streams. These streams sit on top of an already existing input stream (the underlying input stream), but provide additional functionality.

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.


Fields

in

protected InputStream in
The underlying input stream.

Constructors

FilterInputStream

protected FilterInputStream(InputStream in)
Creates an input stream filter built on top of the specified input stream.
Parameters:
in - the underlying input stream

Methods

available

public int available() throws IOException
Determines the number of bytes that can be read from this input stream without blocking.
The available method of FilterInputStream calls the available method of its underlying input stream (I-§2.11.1) and returns whatever value that method returns.

Returns:
the number of bytes that can be read from the input stream without blocking.
Throws
IOException (I-§2.29)
If an I/O error occurs.
Overrides:
available in class InputStream (I-§2.13.2).

close

public void close() throws IOException
Closes this input stream and releases any system resources associated with the stream. The close method of FilterInputStream calls the close method of its underlying input stream (I-§2.11.1).

Throws
IOException (I-§2.29)
If an I/O error occurs.
Overrides:
close in class InputStream (I-§2.13.3).

mark

public void mark(int readlimit)
Marks the current position in this input stream. A subsequent call to the reset method (I-§2.11.10) repositions this stream at the last marked position so that subsequent reads re-read the same bytes.


The readlimit arguments 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 (I-§2.11.1) with the readlimit argument.

Parameters:
readlimit - the maximum limit of bytes that can be read before the mark position becomes invalid.
Overrides:
mark in class InputStream (I-§2.13.4).

markSupported

public boolean markSupported()
Determines if this input stream supports the mark (I-§2.13.4) and reset (I-§2.13.9) methods. The markSupported method of FilterInputStream calls the markSupported method of its underlying input stream (I-§2.11.1) and returns whatever value that method returns.

Returns:
true if this stream type supports the mark and reset method; false otherwise.
Overrides:
markSupported in class InputStream (I-§2.13.5).

read

public int read() throws IOException
Reads the next byte of data from this stream from this input stream. The value byte is returned as an 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 either 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 (I-§2.11.1) and returns whatever value that method returns.

Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws
IOException (I-§2.29)
If an I/O error occurs.
Overrides:
read in class InputStream (I-§2.13.6).

read

public int read(byte b[]) throws IOException
Reads up to 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 (I-§2.11.9) 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.
Parameters:
b - the buffer into which the data is read
Returns:
the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached.
Throws
IOException (I-§2.29)
If an I/O error occurs.
Overrides:
read in class InputStream (I-§2.13.7).

read

public int read(byte b[], int off, int len) throws IOException
Reads up to 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 (I-§2.11.1) with the same arguments and returns whatever value that method returns.

Parameters:
b - the buffer into which the data is read
off - the start offset of the data
len - the maximum number of bytes read
Returns:
the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached.
Throws
IOException (I-§2.29)
If an I/O error occurs.
Overrides:
read in class InputStream (I-§2.13.8).

reset

public void reset() throws IOException
Repositions this stream to the position at the time the mark method (I-§2.11.5) was last called on this input stream


The reset method of FilterInputStream calls the reset method of its underlying input stream (I-§2.11.1).

Throws
IOException (I-§2.29)
If the stream has not been marked or if the mark has been invalidated.
Overrides:
reset in class InputStream (I-§2.13.9).

skip

public long skip(long n) throws IOException
Skips over and discards 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 zero. The actual number of bytes skipped is returned.
The skip method of FilterInputStream calls the skip method of its underlying input stream (I-§2.11.1) with the same argument, and returns whatever value that method does.

Parameters:
n - the number of bytes to be skipped
Returns:
the actual number of bytes skipped.
Throws
IOException (I-§2.29)
If an I/O error occurs.
Overrides:
skip in class InputStream (I-§2.13.10).

Packages  This Package  Prev  Next  Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com