public static class TemporaryBuffer.LocalFile extends TemporaryBuffer
Initially this output stream buffers to memory and is therefore similar to ByteArrayOutputStream, 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 TemporaryBuffer.close().
TemporaryBuffer.Heap, TemporaryBuffer.LocalFileDEFAULT_IN_CORE_LIMIT| Constructor and Description |
|---|
TemporaryBuffer.LocalFile()
Create a new temporary buffer.
|
TemporaryBuffer.LocalFile(File directory)
Create a new temporary buffer, limiting memory usage.
|
TemporaryBuffer.LocalFile(File directory,
int inCoreLimit)
Create a new temporary buffer, limiting memory usage.
|
TemporaryBuffer.LocalFile(int inCoreLimit)
Create a new temporary buffer, limiting memory usage.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
InputStream |
openInputStream()
Open an input stream to read from the buffered data.
|
protected OutputStream |
overflow()
Open the overflow output stream, so the remaining output can be stored.
|
byte[] |
toByteArray()
Convert this buffer's contents into a contiguous byte array.
|
void |
writeTo(OutputStream os,
ProgressMonitor pm)
Send this buffer to an output stream.
|
close, copy, doFlush, reset, write, writeflush, writepublic TemporaryBuffer.LocalFile()
public TemporaryBuffer.LocalFile(int inCoreLimit)
inCoreLimit - maximum number of bytes to store in memory. Storage beyond
this limit will use the local file.public TemporaryBuffer.LocalFile(File directory)
directory - if the buffer has to spill over into a temporary file, the
directory where the file should be saved. If null the
system default temporary directory (for example /tmp) will
be used instead.public TemporaryBuffer.LocalFile(File directory, int inCoreLimit)
directory - if the buffer has to spill over into a temporary file, the
directory where the file should be saved. If null the
system default temporary directory (for example /tmp) will
be used instead.inCoreLimit - maximum number of bytes to store in memory. Storage beyond
this limit will use the local file.protected OutputStream overflow() throws IOException
TemporaryBufferoverflow in class TemporaryBufferIOException - the buffer cannot create the overflow stream.public long length()
TemporaryBuffer
The length is only accurate after TemporaryBuffer.close() has been invoked.
length in class TemporaryBufferpublic byte[] toByteArray()
throws IOException
TemporaryBuffer
The buffer is only complete after TemporaryBuffer.close() has been invoked.
toByteArray in class TemporaryBufferTemporaryBuffer.length().IOException - an error occurred reading from a local temporary filepublic void writeTo(OutputStream os, ProgressMonitor pm) throws IOException
TemporaryBuffer
This method may only be invoked after TemporaryBuffer.close() has completed
normally, to ensure all data is completely transferred.
writeTo in class TemporaryBufferos - stream to send this buffer's complete content to.pm - if not null progress updates are sent here. Caller should
initialize the task and the number of work units to
TemporaryBuffer.length()/1024.IOException - an error occurred reading from a temporary file on the local
system, or writing to the output stream.public InputStream openInputStream() throws IOException
TemporaryBuffer
This method may only be invoked after TemporaryBuffer.close() has completed
normally, to ensure all data is completely transferred.
openInputStream in class TemporaryBufferIOException - an error occurred opening the temporary file.public void destroy()
TemporaryBufferdestroy in class TemporaryBufferCopyright © 2014. All rights reserved.