What is I/O Filter in Java?

Like I/O streams , Filter streams are also used to manipulate data reading from an underlying stream . The filtering done by the streams depends on the stream. The read method in a readable filter stream reads input from the underlying stream, filters it, and passes on the filtered data to the caller. The write method in a writable filter stream filters the data and then writes it to the underlying stream. Java.io.FilterOutputStream class is the superclass of all those classes which filters output streams. FilterInputStream and FilterOutputStream on byte stream side and FilterReader and FilterWriter on character streams side. Most filter streams provided by the java.io package are subclasses of FilterInputStream are follows:
  1. DataInputStream and DataOutputStream
  2. BufferedInputStream and BufferedOutputStream
  3. LineNumberInputStream
  4. PushbackInputStream
  5. PrintStream
By using these streams, there is no need to convert the data from byte to char while writing to a file. These are the more powerful streams than the other streams of Java.