? QueueOutputStream
java.lang.Object
java.io.OutputStream
org.apache.commons.io.output.QueueOutputStream
- ????????:
Closeable
,Flushable
,AutoCloseable
Simple alternative to JDK
PipedOutputStream
; queue input stream provides what's written in queue
output stream.
Example usage:
QueueOutputStream outputStream = new QueueOutputStream(); QueueInputStream inputStream = outputStream.newPipeInputStream(); 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 QueueOutputStream
has no effect. The methods in this class can be called after the stream has been
closed without generating an IOException
.
- ???????:
- 2.9.0
- ????:
-
?????
????????Constructs a new instance with no limit to internal buffer size.QueueOutputStream
(BlockingQueue<Integer> blockingQueue) Constructs a new instance with given buffer. -
????
??????????Creates a new QueueInputStream instance connected to this.void
write
(int b) Writes a single byte.??????? java.io.OutputStream
close, flush, nullOutputStream, write, write
-
???????
-
QueueOutputStream
public QueueOutputStream()Constructs a new instance with no limit to internal buffer size. -
QueueOutputStream
Constructs a new instance with given buffer.- ??:
blockingQueue
- backing queue for the stream
-
-
??????
-
newQueueInputStream
Creates a new QueueInputStream instance connected to this. Writes to this output stream will be visible to the input stream.- ??:
- QueueInputStream connected to this stream
-
write
Writes a single byte.- ???:
write
???OutputStream
- ??:
InterruptedIOException
- if the thread is interrupted while writing to the queue.
-