Package io.micronaut.core.io.buffer
Interface ReadBufferFactory.BufferingOutputStream
- All Superinterfaces:
AutoCloseable,Closeable
- Enclosing class:
ReadBufferFactory
Wrapper around a
OutputStream that buffers into a
ReadBuffer. Must be closed after use, even if
finishBuffer() has not been called (e.g. on error), to avoid resource leaks.-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close this buffer.Finalize this buffer, returning it as aReadBuffer.stream()Get the stream you can write to.
-
Method Details
-
stream
Get the stream you can write to. May be called multiple times.- Returns:
- The
OutputStream - Throws:
IllegalStateException- If the buffer has alreadybeen finalized
-
finishBuffer
Finalize this buffer, returning it as aReadBuffer. This method can only be called once. Release ownership of the buffer transfers to the caller: Closing thisReadBufferFactory.BufferingOutputStreamafter this method has been called will not close the returnedReadBuffer.- Returns:
- The finished buffer
- Throws:
IOException- If there was an exception finishing up the bufferIllegalStateException- If this method has already been called
-
close
Close this buffer.finishBuffer()cannot be called after this method. If it has not been called yet, the content of this buffer will be discarded.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- If there was an exception finishing up the buffer
-