2 replies
by java guru
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.
Trending Web Development posts
Sort by Trending