Friday, 19 May 2017

What is PipedInputStream Class In Java ?

Class PipedInputStream

All Implemented Interfaces:
Closeable, AutoCloseable

Declaration of PipedInputStream:
public class PipedInputStream
extends InputStream

A pipedinputstream should be connected to a piped output stream; the piped input stream then provides whatever data bytes are written to the piped output stream. 

Typically, data is read from a PipedInputStream object by one thread and data is written to the corresponding PipedOutputStream by some other thread. 

Attempting to use both objects from a single thread is not recommended, as it may deadlock the thread. The piped input stream contains a buffer, decoupling read operations from write operations, within limits. A pipe is said to be broken if a thread that was providing data bytes to the connected piped output stream is no longer alive.

Constructor Summary of PipedInputStream :

Constructor
Description
PipedInputStream()
Creates a PipedInputStream so that it is not yet connected.
PipedInputStream(int pipeSize)
Creates a PipedInputStream so that it is not yet connected and uses the specified pipe size for the pipe's buffer.
PipedInputStream(PipedOutputStream src)
Creates a PipedInputStream so that it is connected to the piped output stream src.
PipedInputStream(PipedOutputStream src, int pipeSize)
Creates a PipedInputStream so that it is connected to the piped output stream src and uses the specified pipe size for the pipe's buffer.

Method Summary of PipedInputStream :

Modifier
Method Name
Description
int
available()
Returns the number of bytes that can be read from this input stream without blocking.
void
close()
Closes this piped input stream and releases any system resources associated with the stream.
void
connect(PipedOutputStream src)
Causes this piped input stream to be connected to the piped output stream src.
int
read()
Reads the next byte of data from this piped input stream.
int
read(byte[] b, int off, int len)
Reads up to len bytes of data from this piped input stream into an array of bytes.
protected void
receive(int b)
Receives a byte of data.


      
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.

No comments:

Post a Comment