public class FilterInputStream extends InputStream
InputStream
and simply redirects calls made to it to the subordinate InputStream
instead. Subclasses of this class perform additional filtering
functions in addition to simply redirecting the call.
This class is not abstract. However, since it only redirects calls
to a subordinate InputStream
without adding any functionality
on top of it, this class should not be used directly. Instead, various
subclasses of this class should be used. This is enforced with a
protected constructor. Do not try to hack around it.
When creating a subclass of FilterInputStream
, override the
appropriate methods to implement the desired filtering. However, note
that the read(byte[])
method does not need to be overridden
as this class redirects calls to that method to
read(byte[], int, int)
instead of to the subordinate
InputStream read(byte[])
method.
Modifier and Type | Method and Description |
---|---|
int |
available()
Calls the
in.available() method. |
void |
close()
This method closes the input stream by closing the input stream that
this object is filtering.
|
void |
mark(int readlimit)
Calls the
in.mark(int) method. |
boolean |
markSupported()
Calls the
in.markSupported() method. |
int |
read()
Calls the
in.read() method |
int |
read(byte[] buf)
Calls the
read(byte[], int, int) overloaded method. |
int |
read(byte[] buf,
int offset,
int len)
Calls the
in.read(byte[], int, int) method. |
void |
reset()
Calls the
in.reset() method. |
long |
skip(long numBytes)
Calls the
in.skip(long) method |
public int available() throws IOException
in.available()
method.available
in class InputStream
in.available()
IOException
- If an error occurspublic void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
- If an error occurspublic void mark(int readlimit)
in.mark(int)
method.mark
in class InputStream
readlimit
- The parameter passed to in.mark(int)
public boolean markSupported()
in.markSupported()
method.markSupported
in class InputStream
true
if mark/reset is supported, false
otherwisepublic int read() throws IOException
in.read()
methodread
in class InputStream
in.read()
IOException
- If an error occurspublic int read(byte[] buf) throws IOException
read(byte[], int, int)
overloaded method.
Note that
this method does not redirect its call directly to a corresponding
method in in
. This allows subclasses to override only the
three argument version of read
.read
in class InputStream
buf
- The buffer to read bytes intoin.read(byte[], int, int)
IOException
- If an error occurspublic int read(byte[] buf, int offset, int len) throws IOException
in.read(byte[], int, int)
method.read
in class InputStream
buf
- The buffer to read bytes intooffset
- The index into the buffer to start storing byteslen
- The maximum number of bytes to read.in.read(byte[], int, int)
IOException
- If an error occurspublic void reset() throws IOException
in.reset()
method.reset
in class InputStream
IOException
- If an error occurspublic long skip(long numBytes) throws IOException
in.skip(long)
methodskip
in class InputStream
numBytes
- The requested number of bytes to skip.in.skip(long)
IOException
- If an error occurs