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.
The FilterInputStream class is thus a Decorator that can be wrapped around any input stream class. It is essentially an abstract class that doesn’t do any processing, but provides a layer where the relevant methods have been duplicated. It normally forwards these method calls to the enclosed parent stream class. The interesting classes derived from FilterInputStream include:
BufferedInputStream Adds buffering to stream so that every call does
not cause I/O to occur.
CheckedInputStream Maintains a checksum of bytes as they are read
DataInputStream Reads primitive types (Long, Boolean, Float, etc.)
from the input stream.
DigestInputStream Computes a MessageDigest of any input stream.
InflaterInputStream Implements methods for uncompressing data.
PushbackInputStream Provides a buffer where data can be “unread,” if
during parsing you discover you need to back up.
看了看Decorator设计模式,本想留个笔记,看了此文,觉得经典,原样转来