SequenceInputStream Concatenates multiple input streams. ObjectInputStream and ObjectOutputStream Use for object serialization. LineNumberReader For reading while keep tracking of the line number. Stream chaining is a way of connecting several stream classes together to get the data in the form required. Each class performs a specific task on the data and forwards it to the next class in the chain.
Stream chaining can be very handy.
The following figure portrays chaining three classes to convert raw data into compressed and encrypted data that is stored in a local file. CryptOutputStream encrypts the data prior to forwarding it to FileOutputStream , which writes it out to a file. The result is a file that contains encrypted and compressed data. You might also find the Java Tutorial helpful. Reader Feedback Tell us what you think of this article.