Package org.xnio.streams
Class BufferPipeOutputStream
java.lang.Object
java.io.OutputStream
org.xnio.streams.BufferPipeOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
An
OutputStream implementation which writes out ByteBuffers to a consumer.-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionBufferPipeOutputStream(BufferPipeOutputStream.BufferWriter bufferWriterTask) Construct a new instance. -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
BufferPipeOutputStream
public BufferPipeOutputStream(BufferPipeOutputStream.BufferWriter bufferWriterTask) throws IOException Construct a new instance. The internal buffers will have a capacity ofbufferSize. The givenbufferWriterTaskwill be called to send buffers, flush the output stream, and handle the end-of-file condition.- Parameters:
bufferWriterTask- the writer task- Throws:
IOException- if an error occurs while initializing the stream
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
breakPipe
Break the pipe and return any filling pooled buffer. Sets the stream to an EOF condition. Callers to this method should ensure that any threads blocked onBufferPipeOutputStream.BufferWriter.accept(org.xnio.Pooled, boolean)are unblocked, preferably with aBrokenPipeException.- Returns:
- the current pooled buffer, or
nullif none was pending
-