Methods Summary |
---|
public void | close()Closes this stream. If this stream is connected to an input stream, the
input stream is closed and the pipe is disconnected.
// Is the pipe connected?
if (dest != null) {
dest.done();
dest = null;
}
|
public void | connect(java.io.PipedInputStream stream)Connects this stream to a {@link PipedInputStream}. Any data written to
this output stream becomes readable in the input stream.
if (null == stream) {
throw new NullPointerException();
}
if (this.dest != null) {
throw new IOException(Msg.getString("K0079")); //$NON-NLS-1$
}
synchronized (stream) {
if (stream.isConnected) {
throw new IOException(Msg.getString("K007a")); //$NON-NLS-1$
}
stream.buffer = new byte[PipedInputStream.PIPE_SIZE];
stream.isConnected = true;
this.dest = stream;
}
|
public void | flush()Notifies the readers of this {@link PipedInputStream} that bytes can be
read. This method does nothing if this stream is not connected.
if (dest != null) {
synchronized (dest) {
dest.notifyAll();
}
}
|
public void | write(byte[] buffer, int offset, int count)Writes {@code count} bytes from the byte array {@code buffer} starting at
{@code offset} to this stream. The written data can then be read from the
connected input stream.
Separate threads should be used to write to a {@code PipedOutputStream}
and to read from the connected {@link PipedInputStream}. If the same
thread is used, a deadlock may occur.
// BEGIN android-note
// changed array notation to be consistent with the rest of harmony
// END android-note
if (dest == null) {
// K007b=Pipe Not Connected
throw new IOException(Msg.getString("K007b")); //$NON-NLS-1$
}
super.write(buffer, offset, count);
|
public void | write(int oneByte)Writes a single byte to this stream. Only the least significant byte of
the integer {@code oneByte} is written. The written byte can then be read
from the connected input stream.
Separate threads should be used to write to a {@code PipedOutputStream}
and to read from the connected {@link PipedInputStream}. If the same
thread is used, a deadlock may occur.
if (dest == null) {
throw new IOException(Msg.getString("K007b")); //$NON-NLS-1$
}
dest.receive(oneByte);
|