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.IOException
public OutputStreamPipe()
public void connect(InputStreamPipe sink) throws java.io.IOException
sink
- pipe to connect tojava.io.IOException
public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
b
- the byte of data to writejava.io.IOException
public void write(byte[] buf, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
buf
- array holding data to putoff
- offset of first byte to putlen
- number of bytes to putjava.io.IOException
public void flush()
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.OutputStream
java.io.IOException