Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Introduction to Filter I/O Streams 
 

As mentioned earlier, The InputStream and OutputStream classes are used for reading from and writing to byte streams, respectively.

 

Introduction to Filter I/O Streams

                         

Introduction:

As mentioned earlier, The InputStream and OutputStream  classes are used for reading from and writing to byte streams, respectively. In this section, you are going to learn of data transforming and manipulating using Filter Streams

Like I/O streams, Filter streams are also used to manipulate data reading from an underlying stream. Apart from this, it allows the user to make a chain using multiple input stream so that, the operations that are to be applied on this chain, may create a combine effects on several filters. 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.

The class hierarchy of the Filter streams derived from I/O streams can be shown as:

There are two streams, that are derived from the I/O stream class:

  • FilterInputStream
  • FilterOutputstream

FilterInputStream:

FilterInputStream is the base class for all the input stream filters and is obtained from the InputStream class. It simply overrides all the methods of the InputStream class required to filter data. These methods performs some sort of filtering operations on the data and cannot be instantiated directly. It provides the additional and chaining functionality for the multiple input streams to be filtered.

The constructor of the FilterInputStream is written as:

FilterInputStream fis = new FilterInputStream(Inputstream in); 

FilterOutputstream:

FilterOutputStream is the super class of all the output stream filters and is obtained from the OutputStream class. It simply overrides all the methods of the OutputStream class required to filter the data that is written to the output stream.

FilterIntputStream and FilterOutputStream do not perform any filtering themselves; this is done by their subclasses. To improve the performance of these I/O streams, their subclasses BufferedInputStream and BufferedOutputStream are used.

BufferedInputStream:

This class is a subclass of the FilterInputstream class that lets you read large amount of data from a stream and store it in an internal buffer. When data is requested, it is usually read from the buffer. This has the effect for improving the performance of some input streams, especially for those, that are bounded to slower sources like a file or network connection.

The constructor of the BufferedInputStream is written as:

BufferedInputStream (java.io.InputStream in);

BufferedOutputStream:

This is a subclass of the BufferedOutputStream and a buffered output stream that lets you write characters to a stream. A BufferedOutputStream adds functionality to another output stream. The data is first written into a buffer. When the BufferedOutputStream is created, an internal buffer array is also created, in which the bytes are stored.

The constructor of the BufferedOutputStream is written as:

BufferedOutputStream (java.io.OutputStream out);

 

                         

» View all related tutorials
Related Tags: c orm form time script object io objects help method sed system ip collection this opera create show for work

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.