public class QueueInputStream
extends java.io.InputStream
PipedInputStream; queue input stream provides what's written in queue
output stream.
Example usage:
QueueInputStream inputStream = new QueueInputStream();
QueueOutputStream outputStream = inputStream.newQueueOutputStream();
outputStream.write("hello world".getBytes(UTF_8));
inputStream.read();
Unlike JDK PipedInputStream and PipedOutputStream, queue input/output streams may be used safely in a
single thread or multiple threads. Also, unlike JDK classes, no special meaning is attached to initial or current
thread. Instances can be used longer after initial threads exited.
Closing a QueueInputStream has no effect. The methods in this class can be called after the stream has been
closed without generating an IOException.
QueueOutputStream| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.BlockingQueue<java.lang.Integer> |
blockingQueue |
| Constructor and Description |
|---|
QueueInputStream()
Constructs a new instance with no limit to its internal buffer size.
|
QueueInputStream(java.util.concurrent.BlockingQueue<java.lang.Integer> blockingQueue)
Constructs a new instance with given buffer
|
| Modifier and Type | Method and Description |
|---|---|
QueueOutputStream |
newQueueOutputStream()
Creates a new QueueOutputStream instance connected to this.
|
int |
read()
Reads and returns a single byte.
|
private final java.util.concurrent.BlockingQueue<java.lang.Integer> blockingQueue
public QueueInputStream()
public QueueInputStream(java.util.concurrent.BlockingQueue<java.lang.Integer> blockingQueue)
blockingQueue - backing queue for the streampublic QueueOutputStream newQueueOutputStream()
public int read()
read in class java.io.InputStream-1 if the end of the stream has been reached