Discussion Locked

Transfer data by piping data streams

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
The Dec. 16, Java TechMail discusses piping input and output with the PipedInputStream and PipedOutputStream classes. Have you used piping in your Java application development?

2 replies

by java guru

The article states, "This coarse example is not the normal, or even desired, usage of piped streams". OK, so give me an example that shows me why I would want to use this. I do not doubt the usefulness of the object, just lack a useful applicationof the object.

by bayard-generationjava

The main reason for the example not being desired is due to the threading limitation. We can't have infinitely sized buffers in our pipe, so different threads are needed.

My classic example of a use of Piped streams has been in a GUI library. I have a ConsoleView widget which works very much like tailing a file on a *nix computer. It shows the last N number of lines in it. It is bound to an InputStream.

If I then have another component who pushes data out to output streams, I can connect the two and just let the system go. [With the thread proviso].

As a sidenote, tips I wrote for Builder can be split into three types. "Here's a neat way of doing standard Java things", "Here's a hidden feature in the JDK" and "Here's a freely available project which you might all find useful". This one is definitely a 'Hidden in the JDK' one. With realisation that plugging these streams together is a simple piece of code, I would hope that the class might get more use amongst us, the great unwashed public.

This discussion is closed to new replies.