java.io.PipedInputStream
A piped input stream 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 are 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.
Implemented Interfaces:
Closeable, AutoCloseable
Some methods of PipedInputStream class
close(): This method closes this piped input stream and releases any system resources associated with the stream.
connect(PipedOutputStream): This method causes this piped input stream to be connected to the piped output stream src.
available(): This method returns the number of bytes that can be read from this input stream without blocking.
PipedInputStream(): This method creates a PipedInputStream so that it is not yet connected.
PipedInputStream(int): This method creates a PipedInputStream so that it is not yet connected and uses the specified pipe size for the pipe's buffer.
PipedInputStream(PipedOutputStream): This method creates a PipedInputStream so that it is connected to the piped output stream src.
PipedInputStream(PipedOutputStream, int): This method 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.
read(): This method reads the next byte of data from this piped input stream.
read(byte[], int, int): This method reads up to len bytes of data from this piped input stream into an array of bytes.
No comments:
Post a Comment