|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Reader
java.io.PipedReader
public class PipedReader
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.
| Field Summary |
|---|
| Fields inherited from class java.io.Reader |
|---|
lock |
| Constructor Summary | |
|---|---|
PipedReader()
Constructs a new unconnected PipedReader. |
|
PipedReader(PipedWriter out)
Constructs a new PipedReader connected to the PipedWriter out. |
|
| Method Summary | |
|---|---|
void |
close()
Close this PipedReader. |
void |
connect(PipedWriter src)
Connects this PipedReader to a PipedWriter. |
(package private) void |
done()
|
(package private) void |
establishConnection()
Establish the connection to the PipedWriter. |
(package private) void |
flush()
|
int |
read()
Reads the next character from this Reader. |
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. |
boolean |
ready()
Answer a boolean indicating whether or not this Reader is ready to be read. |
(package private) void |
receive(char oneChar)
Receives a char and stores it into the PipedReader. |
(package private) void |
receive(char[] chars,
int offset,
int count)
Receives a char array and stores it into the PipedReader. |
| Methods inherited from class java.io.Reader |
|---|
mark, markSupported, read, read, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PipedReader()
public PipedReader(PipedWriter out)
throws IOException
out. Any data written to the writer can be read from the
this reader.
out - the PipedWriter to connect to.
IOException - if this or out are already connected.| Method Detail |
|---|
public void close()
throws IOException
close in interface Closeableclose in class ReaderIOException - If an error occurs attempting to close this reader.
public void connect(PipedWriter src)
throws IOException
src - the source PipedWriter.
IOException - If either Writer or Reader is already connected.
void establishConnection()
throws IOException
IOException - If this Reader is already connected.
public int read()
throws IOException
read in class ReaderIOException - If the reader is already closed or another IOException
occurs.
public int read(char[] buffer,
int offset,
int count)
throws IOException
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.
read in class Readerbuffer - the character array in which to store the read characters.offset - the offset in buffer to store the read
characters.count - the maximum number of characters to store in
buffer.
IOException - If the reader is already closed or another IOException
occurs.
public boolean ready()
throws IOException
ready in class Readertrue if there are characters ready,
false otherwise.
IOException - If the reader is already closed or another IOException
occurs.
void receive(char oneChar)
throws IOException
If the buffer is full and the thread sending #receive is interrupted, the InterruptedIOException will be thrown.
oneChar - the char to store into the pipe.
IOException - If the stream is already closed or another IOException
occurs.
void receive(char[] chars,
int offset,
int count)
throws IOException
If the buffer is full and the thread sending #receive is interrupted, the InterruptedIOException will be thrown.
chars - the char array to store into the pipe.offset - offset to start reading fromcount - total characters to read
IOException - If the stream is already closed or another IOException
occurs.void done()
void flush()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||