What are use cases of Piped streams? Why just not read data into buffer and then write them out?
5 Answers
BlockingQueue or similiar collections may serve you better, which is thread safe, robust, and scales better.

- 958
- 2
- 13
- 18
Pipes in Java IO provides the ability for two threads running in the same JVM to communicate. As such pipes are a common source or destination of data.
This useful if you have two long running Threads and one is setup to produce data and the other consume it.

- 24,113
- 5
- 60
- 79
As the other answers have said, they are designed for use between threads. In practice they are best avoided. I've used them once in 13 years and I wish I hadn't.

- 305,947
- 44
- 307
- 483
-
1It was just a ghastly solution. It's 13 years ago so I can't remember the details but I should have been using some kind of a Queue. In fact I think I did in the end. – user207421 Aug 05 '10 at 11:00
-
@downvoter Your motive please. I did have this experience; I subsequently had 16 further years of Java; and I was not exactly a novice beforehand. It's a very considered judgement. – user207421 Oct 18 '13 at 19:39
They are usually used for simultaneously reading and writing, usually by two different threads.
(They design is quite bad. You can't switch threads at one end and then have that thread exit without disrupting the pipe.)

- 145,806
- 30
- 211
- 305
One advantage of using Piped streams is that they provide stream functionality in our code without compelling us to build new specialized streams.
For e.g. we can use pipes to create simple logging facility for our application.We can send messages to logging facility through ordinaty Printwritter and then it can do whatever processing or buffering is required before sending message off to final destination.
more details refer : http://docstore.mik.ua/orelly/java/exp/ch08_01.htm

- 14,329
- 4
- 49
- 67