| |
|
| java.lang.Object java.io.Reader java.io.PipedReader
PipedReader | public class PipedReader extends Reader (Code) | | PipedReader is a class which receives information on a communications pipe.
When two threads want to pass data back and forth, one creates a piped writer
and the other creates a piped reader.
|
Constructor Summary | |
public | PipedReader() Constructs a new unconnected PipedReader. | public | PipedReader(PipedWriter out) Constructs a new PipedReader connected to the PipedWriter
out . |
Method Summary | |
public void | close() Close this PipedReader. | public void | connect(PipedWriter src) Connects this PipedReader to a PipedWriter. | void | done() | void | establishConnection() Establish the connection to the PipedWriter. | void | flush() | public int | read() Reads the next character from this Reader. | public int | read(char[] buffer, int offset, int count) Reads at most count character from this PipedReader and
stores them in char array buffer starting at
offset . | public boolean | ready() Answer a boolean indicating whether or not this Reader is ready to be
read. | void | receive(char oneChar) Receives a char and stores it into the PipedReader. | void | receive(char[] chars, int offset, int count) Receives a char array and stores it into the PipedReader. |
PipedReader | public PipedReader()(Code) | | Constructs a new unconnected PipedReader. The resulting Reader must be
connected to a PipedWriter before data may be read from it.
|
PipedReader | public PipedReader(PipedWriter out) throws IOException(Code) | | Constructs a new PipedReader connected to the PipedWriter
out . Any data written to the writer can be read from the
this reader.
Parameters: out - the PipedWriter to connect to. throws: IOException - if this or out are already connected. |
close | public void close() throws IOException(Code) | | Close this PipedReader. This implementation releases the buffer used for
the pipe and notifies all threads waiting to read or write.
throws: IOException - If an error occurs attempting to close this reader. |
connect | public void connect(PipedWriter src) throws IOException(Code) | | Connects this PipedReader to a PipedWriter. Any data written to the
Writer becomes available in this Reader.
Parameters: src - the source PipedWriter. throws: IOException - If either Writer or Reader is already connected. |
establishConnection | void establishConnection() throws IOException(Code) | | Establish the connection to the PipedWriter.
throws: IOException - If this Reader is already connected. |
read | public int read() throws IOException(Code) | | Reads the next character from this Reader. Answer the character actually
read or -1 if no character was read and end of reader was encountered.
Separate threads should be used for the reader of the PipedReader and the
PipedWriter. There may be undesirable results if more than one Thread
interacts a reader or writer pipe.
int the character read -1 if end of reader. throws: IOException - If the reader is already closed or another IOExceptionoccurs. |
read | public int read(char[] buffer, int offset, int count) throws IOException(Code) | | Reads at most count character from this PipedReader and
stores them in char array buffer starting at
offset . Answer the number of characters actually read or
-1 if no characters were read and end of stream was encountered. Separate
threads should be used for the reader of the PipedReader and the
PipedWriter. There may be undesirable results if more than one Thread
interacts a reader or writer pipe.
Parameters: buffer - the character array in which to store the read characters. Parameters: offset - the offset in buffer to store the readcharacters. Parameters: count - the maximum number of characters to store inbuffer . int the number of characters actually read or -1 if end ofreader. throws: IOException - If the reader is already closed or another IOExceptionoccurs. |
ready | public boolean ready() throws IOException(Code) | | Answer a boolean indicating whether or not this Reader is ready to be
read. Answers true if the buffer contains characters to be read.
boolean true if there are characters ready,false otherwise. throws: IOException - If the reader is already closed or another IOExceptionoccurs. |
receive | void receive(char oneChar) throws IOException(Code) | | Receives a char and stores it into the PipedReader. This called by
PipedWriter.write() when writes occur.
If the buffer is full and the thread sending #receive is interrupted, the
InterruptedIOException will be thrown.
Parameters: oneChar - the char to store into the pipe. throws: IOException - If the stream is already closed or another IOExceptionoccurs. |
receive | void receive(char[] chars, int offset, int count) throws IOException(Code) | | Receives a char array and stores it into the PipedReader. This called by
PipedWriter.write() when writes occur.
If the buffer is full and the thread sending #receive is interrupted, the
InterruptedIOException will be thrown.
Parameters: chars - the char array to store into the pipe. Parameters: offset - offset to start reading from Parameters: count - total characters to read throws: IOException - If the stream is already closed or another IOExceptionoccurs. |
|
|
|