- java.lang.Object
-
- java.io.OutputStream
-
- org.xnio.streams.BufferPipeOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class BufferPipeOutputStream extends java.io.OutputStreamAnOutputStreamimplementation which writes outByteBuffers to a consumer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceBufferPipeOutputStream.BufferWriterA buffer writer for anBufferPipeOutputStream.
-
Constructor Summary
Constructors Constructor Description BufferPipeOutputStream(BufferPipeOutputStream.BufferWriter bufferWriterTask)Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Pooled<java.nio.ByteBuffer>breakPipe()Break the pipe and return any filling pooled buffer.voidclose()voidflush()voidwrite(byte[] b, int off, int len)voidwrite(int b)
-
-
-
Constructor Detail
-
BufferPipeOutputStream
public BufferPipeOutputStream(BufferPipeOutputStream.BufferWriter bufferWriterTask) throws java.io.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:
java.io.IOException- if an error occurs while initializing the stream
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
breakPipe
public Pooled<java.nio.ByteBuffer> 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
-
-