java.io.PipedReader
java.io.Reader
None
None
New as of JDK 1.1
The PipedReader class represents half of a communication pipe; a PipedReader must be connected to a PipedWriter. When the two halves of a communication pipe are connected, data written to the PipedWriter can be read from the PipedReader. The communication pipe formed by a PipedReader and a PipedWriter should be used to communicate between threads. If both ends of a pipe are used by the same thread, the thread can hang.
The PipedReader class is the character-based equivalent of the byte-based PipedInputStream.
public class java.io.PipedReader extends java.io.Reader { // Constructors public PipedReader(); public PipedReader(PipedWriter src); // Instance Methods public void close(); public void connect(PipedWriter src); public int read(char[] cbuf, int off, int len); }
This constructor creates a PipedReader that is not connected to a PipedWriter. The created object must be connected to a PipedWriter before it can be used.
The PipedWriter to connect.
If any kind of I/O error occurs.
This constructor creates a PipedReader that receives data from the given PipedWriter.
If any kind of I/O error occurs.
Reader.close()
This method closes the reader and releases the system resources that are associated with it.
The PipedWriter to connect.
If another PipedWriter is already connected to this PipedReader.
This method connects the given PipedWriter to this PipedReader object. If there is already a connected PipedWriter, an exception is thrown.
An array of characters to be filled.
An offset into the array.
The number of characters to read.
The actual number of characters read or -1 if the end of the stream is encountered immediately.
If the pipe is broken. In other words, if this PipedReader is closed or if the connected PipedWriter is dead.
While this method is waiting for input, if the interrupted() method of the thread that invoked this method is called.
Reader.read(char[], int, int)
This method copies characters from the pipe buffer into the given array cbuf, starting at index off and continuing for len characters. If there is at least one character in the buffer, the method returns as many characters as are in the buffer (up to len). If the buffer is empty, the method blocks until data is written to the connected PipedWriter.
Method |
Inherited From |
Method |
Inherited From |
---|---|---|---|
clone() |
Object |
equals(Object) |
Object |
finalize() |
Object |
getClass() |
Object |
hashCode() |
Object |
mark(int) |
Reader |
markSupported() |
Reader |
notify() |
Object |
notifyAll() |
Object |
read() |
Reader |
read(char[]) |
Reader |
reset() |
Reader |
skip(long) |
Reader |
toString() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
IOException, PipedInputStream, PipedWriter, Reader