|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
org.exist.storage.io.BlockingInputStream
public class BlockingInputStream
BlockingInputStream
is a combination of an input stream and
an output stream, connected through a (circular) buffer in memory.
It is intended for coupling producer threads to consumer threads via a
(byte) stream.
When the buffer is full producer threads will be blocked until the buffer
has some free space again. When the buffer is empty the consumer threads will
be blocked until some bytes are available again.
Closing of the output stream will block until the inputstream is closed.
A special version of the close function enables the consumer threads to
specify that an exception has occurred. This will cause producer calls to
be unblocked and throw an IOException containing this exception as cause.
Constructor Summary | |
---|---|
BlockingInputStream()
|
Method Summary | |
---|---|
int |
available()
The number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. |
void |
close()
Closes this input stream and releases the buffer associated with this stream. |
void |
close(Exception ex)
Closes this input stream, specifying that an exception has occurred. |
BlockingOutputStream |
getOutputStream()
BlockingOutputStream adapter for this BlockingInputStream. |
int |
read()
Reads the next byte of data from the input stream. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from the input stream into
an array of bytes. |
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, read, reset, skip |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BlockingInputStream()
Method Detail |
---|
public BlockingOutputStream getOutputStream()
public int read() throws IOException
int
in the range 0
to
255
. If no byte is available because the end of the stream
has been reached, the value -1
is returned. This method
blocks until input data is available, the end of the stream is detected,
or an exception is thrown.
read
in class InputStream
-1
if the end of the
stream is reached.
IOException
- if an I/O error occurs.public int read(byte[] b, int off, int len) throws IOException
len
bytes of data from the input stream into
an array of bytes. An attempt is made to read as many as
len
bytes, but a smaller number may be read.
The number of bytes actually read is returned as an integer.
This method blocks until input data is available, end of file is detected, or an exception is thrown.
read
in class InputStream
b
- the buffer into which the data is read.off
- the start offset in array b
at which the data is written.len
- the maximum number of bytes to read.
-1
if there is no more data because the end of
the stream has been reached.
IOException
- if an I/O error occurs.
NullPointerException
- if b
is null
.public void close()
close
in interface Closeable
close
in class InputStream
public void close(Exception ex)
BlockingInputStream
specific method.
public int available()
available
in class InputStream
ExistIOException
- if an I/O error occurs.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |