java.io
public class PipedWriter extends Writer
PipedReader
to
which it is connected.
It is highly recommended that a PipedWriter
and its
connected PipedReader
be in different threads. If
they are in the same thread, read and write operations could deadlock
the thread.
Constructor Summary | |
---|---|
PipedWriter()
Create an unconnected PipedWriter. | |
PipedWriter(PipedReader sink)
Create a new PipedWriter instance
to write to the specified PipedReader . |
Method Summary | |
---|---|
void | close()
This method closes this stream so that no more data can be written
to it. |
void | connect(PipedReader sink)
Connects this object to the specified PipedReader
object. |
void | flush()
This method does nothing.
|
void | write(int b)
Write a single char of date to the stream. |
void | write(char[] buffer, int offset, int len)
This method writes len chars of data from the char array
buf starting at index offset in the array
to the stream. |
PipedReader
using the connect
method prior to writing any data or an exception will be thrown.PipedWriter
instance
to write to the specified PipedReader
. This stream
is then ready for writing.
Parameters: sink The PipedReader
to connect this stream to.
Throws: IOException If sink
has already been connected
to a different PipedWriter.
Throws: IOException If an error occurs
PipedReader
object. This stream will then be ready for writing.
Parameters: sink The PipedReader
to connect this stream to
Throws: IOException If the stream has not been connected or has been closed.
Throws: IOException If the stream is closed.
UNKNOWN: You'd think that this method would block until the sink had read all available data. Thats not the case - this method appears to be a no-op?
PipedReader
to which this object is
connected has a full buffer.
Parameters: b The char of data to be written, passed as an int
.
Throws: IOException If the stream has not been connected or has been closed.
len
chars of data from the char array
buf
starting at index offset
in the array
to the stream. Note that this method will block if the
PipedReader
to which this object is connected has
a buffer that cannot hold all of the chars to be written.
Parameters: buffer The array containing chars to write to the stream. offset The index into the array to start writing chars from. len The number of chars to write.
Throws: IOException If the stream has not been connected or has been closed.