Filtering a Stream

Filtered streams are streams that modify the information sent through an existing stream. They are created using one of the subclasses FilterInputStream or FilterOutputStream.

These classes do not handle any filtering operations themselves. Instead, they have subclasses such as BufferInputStream and DataOutputStream that handle specific types of filtering.

Byte Filters

Information is delivered more quickly if it can be sent in large chunks, even if those chunks are received faster than they can be handled.

As an example of this, consider which of the following book-reading techniques is faster:

  • A friend loans you a book in its entirety and you read it.

  • A friend loans you a book one page at a time, and doesn't give you a new page ...

Get Sams Teach Yourself Java 2 in 21 Days, Second Edition 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.