Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Piped I/O stream in java

Tags:

java

I am not able to understand the purpose of piped i/o streams in java. If I write something using an outputstream, I can anyways read it again using an inputstream.

So what is the need of a pipedstream?

like image 719
Shashank Gupta Avatar asked Jan 20 '26 17:01

Shashank Gupta


1 Answers

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.

A PipedInputStream should be connected to a PipedOutputStream. The data written to the PipedOutputStream by one thread, can thus be read from the connected PipedInputStream by another thread

Normal Java IO does not support streaming to the same stream from multiple threads.

like image 129
SparkOn Avatar answered Jan 22 '26 08:01

SparkOn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!