Home arrow Java arrow Using Streams in Java

Using Streams in Java

This article, the second of two parts, continues to explain how to use streams with Java to interact with different storage devices. It is excerpted from chapter 15 of the book Sams Teach Yourself Java 2 in 21 days, written by Roger Cadenhead and Laura Lemay (Sams, ISBN: 0672326280).

Author Info:
By: Sams Publishing
Rating: 4 stars4 stars4 stars4 stars4 stars / 16
April 20, 2006
  1. · Using Streams in Java
  2. · Buffered Streams
  3. · Console Input Streams
  4. · Data Streams

print this article

Using Streams in Java
(Page 1 of 4 )

Filtering a Stream

Filtered streams are streams that modify the information sent through an existing stream. They are created using the subclasses FilterInputStream and 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 lends you a book in its entirety and you read it.

  • A friend lends you a book one page at a time and doesn't give you a new page until you have finished the previous one.

Obviously, the first technique is going to be faster and more efficient. The same benefits are true of buffered streams in Java.

A buffer is a storage place where data can be kept before it is needed by a program that reads or writes that data. By using a buffer, you can get data without always going back to the original source of the data.

blog comments powered by Disqus

- Java Too Insecure, Says Microsoft Researcher
- Google Beats Oracle in Java Ruling
- Deploying Multiple Java Applets as One
- Deploying Java Applets
- Understanding Deployment Frameworks
- Database Programming in Java Using JDBC
- Extension Interfaces and SAX
- Entities, Handlers and SAX
- Advanced SAX
- Conversions and Java Print Streams
- Formatters and Java Print Streams
- Java Print Streams
- Wildcards, Arrays, and Generics in Java
- Wildcards and Generic Methods in Java
- Finishing the Project: Java Web Development ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials