Java Io

I've always liked to point out that the InputStream hierarchy in Java (yes, it's JDK 1.0, but it's still there...) is an example of the DecoratorPattern. Specifically, all InputStreams are either leaves (e.g. FileInputStream, StringBufferInputStream) or Decorators (e.g. FilterInputStream and its subclasses). In fact, this hierarchy nicely shows all three ways in which Decorators can extend their "Wrapped" objects, e.g by additional state (LineNumberInputStream), additional methods (PushbackInputStream) or extended core methods (BufferedInputStream).

KyleBrown


EditText of this page (last edited August 8, 2000) or FindPage with title or text search