PipedReader and PipedWriter in java.

You know the power of pipe (“|”) operator in Unix. It helps you to redirect output from one command to another. PipedReader and PipedWriter classes in java.io package helps you to do the same. It helps you to redirect the read input into writer seamlessly. In unix, two process on different address space can communicate using pipe but in java two threads in the same JVM can communicate using Piped ByteStream/CharacterStream.

Below given sample program demonstrate the use piped character streams. This program read from the console and redirect console input to another thread using piped character stream.

One thought on “PipedReader and PipedWriter in java.