|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
com.mindbright.util.InputStreamPipe
An input stream pipe should be connected to an output stream pipe;
the input stream pipe then provides whatever data bytes are
written to the output stream pipe. This is very close to the
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.
OutputStreamPipe
,
PipedInputStream
,
PipedOutputStream
Constructor Summary | |
InputStreamPipe()
Create an unconnected InputStreamPipe with the default circular buffer size (8192 bytes). |
|
InputStreamPipe(int bufferSize)
Create an unconnected InputStreamPipe with the given circular buffer size. |
|
InputStreamPipe(OutputStreamPipe source)
Create an InputStreamPipe with the default circular buffer size (8192 bytes) which is connected to the given output stream. |
Method Summary | |
int |
available()
Returns the number of bytes that can be read without blocking. |
void |
close()
Close this stream and abort any ongoing write operation in the corresponding OutputStreamPipe. |
void |
connect(OutputStreamPipe source)
Causes this InputStreamPipe to be connected to the given OutputStreamPipe. |
protected void |
eof()
Signal that this stream is closing. |
void |
flush()
Notify all instances waiting on this stream. |
protected void |
put(byte[] buf,
int off,
int len)
Put data into this input stream pipe. |
protected void |
put(int b)
Put a byte of data into this input stream pipe. |
int |
read()
Read a byte of data from the pipe. |
int |
read(byte[] buf,
int off,
int len)
Read data from the pipe. |
Methods inherited from class java.io.InputStream |
mark, markSupported, read, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public InputStreamPipe(int bufferSize)
bufferSize
- size of circular bufferpublic InputStreamPipe()
public InputStreamPipe(OutputStreamPipe source) throws java.io.IOException
source
- the output stream to connect toMethod Detail |
public void connect(OutputStreamPipe source) throws java.io.IOException
source
- the stream to connect to
java.io.IOException
public int read() throws java.io.IOException
java.io.IOException
public int read(byte[] buf, int off, int len) throws java.io.IOException
buf
- buffer to store read data intooff
- where in the buffer the first byte should be storedlen
- how many bytes of data to read
java.io.IOException
public int available()
public void close() throws java.io.IOException
java.io.IOException
public void flush()
protected void put(int b) throws java.io.IOException
b
- the byte of data to put
java.io.IOException
protected void put(byte[] buf, int off, int len) throws java.io.IOException
buf
- array holding data to putoff
- offset of first byte to putlen
- number of bytes to put
java.io.IOException
protected void eof()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |