public abstract class FilterReader extends Reader
Reader
and simply redirects calls made to it to the subordinate Reader
instead. Subclasses of this class perform additional filtering
functions in addition to simply redirecting the call.
When creating a subclass of FilterReader
, override the
appropriate methods to implement the desired filtering. However, note
that the read(char[])
method does not need to be overridden
as this class redirects calls to that method to
read(yte[], int, int)
instead of to the subordinate
Reader} read(yte[])
method.
Modifier and Type | Field and Description |
---|---|
protected Reader |
in
This is the subordinate
Reader to which method calls
are redirected |
Modifier | Constructor and Description |
---|---|
protected |
FilterReader(Reader in)
Create a
FilterReader with the specified subordinate
Reader . |
Modifier and Type | Method and Description |
---|---|
void |
close()
This method closes the stream by calling the
close() method
of the underlying stream. |
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(char[] buf,
int offset,
int len)
Calls the
in.read(char[], int, int) method. |
boolean |
ready()
Calls the
in.read() method. |
void |
reset()
Calls the
in.reset() method. |
long |
skip(long num_chars)
Calls the
in.skip(long) method |
protected FilterReader(Reader in)
FilterReader
with the specified subordinate
Reader
.
The lock
of the new FilterReader
will be set
to in.lock
.in
- The subordinate Reader
public void mark(int readlimit) throws IOException
in.mark(int)
method.mark
in class Reader
readlimit
- The parameter passed to in.mark(int)
IOException
- If an error occurspublic boolean markSupported()
in.markSupported()
method.markSupported
in class Reader
true
if mark/reset is supported,
false
otherwisepublic void reset() throws IOException
in.reset()
method.reset
in class Reader
IOException
- If an error occurspublic boolean ready() throws IOException
in.read()
method.ready
in class Reader
in.available()
IOException
- If an error occurspublic long skip(long num_chars) throws IOException
in.skip(long)
methodskip
in class Reader
num_chars
- The requested number of chars to skip.in.skip(long)
IOException
- If an error occurspublic int read() throws IOException
in.read()
methodread
in class Reader
in.read()
IOException
- If an error occurspublic int read(char[] buf, int offset, int len) throws IOException
in.read(char[], int, int)
method.read
in class Reader
buf
- The buffer to read chars intooffset
- The index into the buffer to start storing charslen
- The maximum number of chars to read.in.read(char[], int, int)
IOException
- If an error occurspublic void close() throws IOException
close()
method
of the underlying stream.close
in interface Closeable
close
in class Reader
IOException
- If an error occurs