Filtered Readers and Writers
java.io.FilterWriter classes are abstract classes
that read characters and filter them in some way before passing the
text along. You can imagine a
converts all characters to uppercase.
public abstract class FilterReader extends Reader public abstract class FilterWriter extends Writer
FilterWriter are modeled after
java.io.FilterOutputStream, they are much less
commonly used than those classes. There are no concrete subclasses of
FilterWriter in the
packages and only one concrete subclass of
discussed later). These classes exist so you can write your own
The FilterReader Class
has a single constructor, which is
protected FilterReader(Reader in)
in argument is the
to which this filter is chained. This reference is stored in a
protected field called
in from which text for this
filter is read and is
null after the filter has
protected Reader in
FilterReader is an abstract class, only
subclasses may be instantiated. Therefore, it doesn’t matter
that the constructor is protected, since it may only be invoked from
FilterReader provides the usual collection of
public int read() throws IOException public int read(char text, int offset, int length) throws IOException ...
Get Java I/O now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.