A good answer might be:

Yes. For example, a text editor typically does output to both the monitor and to a disk file. Its input comes from both a disk file and the keyboard.

Processing Streams

A processing stream operates on the data supplied by another stream. Often a processing stream acts as a buffer for the data coming from another stream. A buffer is a block of main memory used as a work area. For example, disk file data usually is delivered by the operating system in blocks of 512 bytes at a time. Usually this data is buffered and delivered to a program in more suitable sizes.

You have seen this before. In the following, the keyboard sends data to the InputStream System.in which is connected to a InputStreamReader stream which is connected to a BufferedReader stream. System.in is a stream object that the Java system automatically creates when your program starts running.

BufferedReader stdin = 
    new BufferedReader( new  InputStreamReader( System.in ) );

The data is transformed along the way. The raw bytes from the keyboard are grouped together into a String object that the program reads using stdin.readLine().

This may seem like an unnecessary complication. But java.io gives you a collection of parts that can be assembled to do nearly any IO task you need.


Might several connected streams be used for output?