public class LargeBufferStream extends OutputStream
Initially this output stream buffers to memory, like ByteArrayOutputStream might do, but it shifts to using an on disk temporary file if the output gets too large.
The content of this buffered stream may be sent to another OutputStream only
after this stream has been properly closed by close().
| Constructor and Description |
|---|
LargeBufferStream()
Create a new empty temporary buffer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
destroy()
Clear this buffer so it has no data, and cannot be used again.
|
long |
length()
Obtain the length (in bytes) of the buffer.
|
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
void |
writeTo(OutputStream os)
Send this buffer to an output stream.
|
flush, writepublic LargeBufferStream()
public void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionpublic long length()
The length is only accurate after close() has been invoked.
public void writeTo(OutputStream os) throws IOException
This method may only be invoked after close() has completed
normally, to ensure all data is completely transferred.
os - stream to send this buffer's complete content to.IOException - an error occurred reading from a temporary file on the local
system, or writing to the output stream.public void destroy()
Copyright © 2016–2022 52°North Initiative for Geospatial Open Source Software GmbH. All rights reserved.