com.mindbright.util
public final class OutputStreamPipe extends java.io.OutputStream
PipedInputStream and
PipedOutputStream. The main difference is that there
is a timeout in the write code so that any waiting write will be
aborted if the pipe is closed.
The input and output pipes are connected via a circular buffer which decouples write and read operations.
InputStreamPipe,
PipedInputStream,
PipedOutputStream| Constructor and Description |
|---|
OutputStreamPipe()
Create an OutputStreamPipe which is not connected to any
InputStreamPipe.
|
OutputStreamPipe(InputStreamPipe sink)
Create an OutputStreamPipe which is connected to the given
InputStreamPipe.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close this output stream pipe.
|
void |
connect(InputStreamPipe sink)
Connect this pipe to an InputStreamPipe
|
void |
flush()
Notify all instances waiting on this stream.
|
void |
write(byte[] buf,
int off,
int len)
Put data into this output stream pipe.
|
void |
write(int b)
Writes a byte of data into this output stream pipe.
|
public OutputStreamPipe(InputStreamPipe sink) throws java.io.IOException
sink - pipe to connect tojava.io.IOExceptionpublic OutputStreamPipe()
public void connect(InputStreamPipe sink) throws java.io.IOException
sink - pipe to connect tojava.io.IOExceptionpublic void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamb - the byte of data to writejava.io.IOExceptionpublic void write(byte[] buf,
int off,
int len)
throws java.io.IOException
write in class java.io.OutputStreambuf - array holding data to putoff - offset of first byte to putlen - number of bytes to putjava.io.IOExceptionpublic void flush()
flush in interface java.io.Flushableflush in class java.io.OutputStreampublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.OutputStreamjava.io.IOException