Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use cases of PipedInputStream and PipedOutputStream

Tags:

java

io

What are use cases of Piped streams? Why just not read data into buffer and then write them out?

like image 801
Illarion Kovalchuk Avatar asked Aug 03 '10 10:08

Illarion Kovalchuk


2 Answers

BlockingQueue or similiar collections may serve you better, which is thread safe, robust, and scales better.

like image 189
Onur Avatar answered Sep 19 '22 05:09

Onur


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.

like image 45
Romain Hippeau Avatar answered Sep 22 '22 05:09

Romain Hippeau