This abstract class is intended
to act as a superclass for
character input streams that read data
from some other character input stream, filter it in some way, and
then return the filtered data when a read(
)
method is called. FilterReader is declared
abstract so that it cannot be instantiated. But
none of its methods are themselves abstract: they all simply call the
requested operation on the input stream passed to the
FilterReader( ) constructor. If you were allowed
to instantiate a FilterReader,
you'd find that it is a null filter (i.e., it simply
reads characters from the specified input stream and returns them
without any kind of filtering).
Because FilterReader implements a null filter, it
is an ideal superclass for classes that want to implement simple
filters but do not want to override all the methods of
Reader. In order to create your own filtered
character input stream, you should subclass
FilterReader and override both its read(
) methods to perform the desired filtering operation. Note
that you can implement one of the read( ) methods
in terms of the other, and thus only implement the filtration once.
Recall that the other read( ) methods defined by
Reader are implemented in terms of these methods,
so you do not need to override those. In some cases, you may need to
override other methods of FilterReader and provide
methods or constructors that are specific to your subclass.
FilterReader is the character-stream analog to
FilterInputStream.
public abstract class FilterReader extends Reader {
// Protected Constructors
protected FilterReader(Reader in);
// Public Methods Overriding Reader
public void close( ) throws IOException;
public void mark(int readAheadLimit) throws IOException;
public boolean markSupported( );
public int read( ) throws IOException;
public int read(char[ ] cbuf, int off, int len) throws IOException;
public boolean ready( ) throws IOException;
public void reset( ) throws IOException;
public long skip(long n) throws IOException;
// Protected Instance Fields
protected Reader in;
}