- Forward


Filtering Streams
in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Filtering Input
Back SMYC Forward
  • FilterInputStream
    • Parent of all filtered input streams
    • By default, performs a simple pass-thru
  • To Filter:
    • Use the protected InputStream in
    • Override:
                    int read()
      int read(byte[] b, int off, int len)
Filtering Output
Back SMYC Forward
  • FilterOutputStream
    • Parent of all filtered output streams
    • By default, performs a simple pass-thru
  • To Filter:
    • Use the protected OutputStream out
    • Override:
                    void write(byte[] b, int off, int len
      void write(byte[] b)
An Example
Back SMYC Forward

A Seven-Bit Input Stream

javaexamples/io/SevenBitInputStream.java
 
There's Always More to Learn
Back -