java.lang.Object
java.io.OutputStream
org.xnio.streams.BufferPipeOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
An
OutputStream
implementation which writes out ByteBuffer
s 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 givenbufferWriterTask
will 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:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in 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
null
if none was pending
-