Package io.micronaut.http.body
Interface ByteBodyFactory.BufferingOutputStream
- All Superinterfaces:
AutoCloseable
,Closeable
- Enclosing class:
- ByteBodyFactory
Wrapper around a
OutputStream
that buffers into a
CloseableAvailableByteBody
. Must be closed after use, even if
finishBuffer()
has not been called (e.g. on error), to avoid resource leaks.- Since:
- 4.10.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this buffer.Finalize this buffer, returning it as aCloseableAvailableByteBody
.stream()
Get the stream you can write to.
-
Method Details
-
stream
Get the stream you can write to.- Returns:
- The
OutputStream
- Throws:
IllegalStateException
- If the buffer has alreadybeen finalized
-
finishBuffer
@NonNull @NonNull CloseableAvailableByteBody finishBuffer() throws IOException, IllegalStateExceptionFinalize this buffer, returning it as aCloseableAvailableByteBody
. This method can only be called once. Release ownership of the buffer transfers to the caller: Closing thisByteBodyFactory.BufferingOutputStream
after this method has been called will not close the returnedCloseableAvailableByteBody
.- 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- If there was an exception finishing up the buffer
-