public class FileBackedBuffer extends OutputStream
A buffer which accepts data and buffers it. The data can be obtained again by reading an input stream. If the data grows too large (user definable) it can flush the data into a tempfile. This class is not threadsafe of course.
Because this class may retain a file it is important that it gets cleaned up after use by calling discard().
| Constructor and Description |
|---|
FileBackedBuffer() |
FileBackedBuffer(int size) |
FileBackedBuffer(int size,
int initial) |
| Modifier and Type | Method and Description |
|---|---|
File |
asFile() |
void |
clear()
Removes all contents from this thingy, and reopens it as an
output stream.
|
void |
close()
This closes the write channel.
|
void |
copy(OutputStream os)
Sends all of the contained data to the outputstream.
|
void |
discard()
This MUST be called after use.
|
protected void |
finalize()
This finalizer at least tries to cleanup the mess if discard() was not called...
|
InputStream |
getInputStream()
Returns an inputstream which reads this.
|
int |
size() |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
flush, writepublic FileBackedBuffer()
public FileBackedBuffer(int size)
public FileBackedBuffer(int size,
int initial)
public void discard()
protected void finalize()
throws Throwable
finalize in class ObjectThrowableObject.finalize()public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionOutputStream.close()public File asFile() throws IOException
IOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOExceptionpublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void clear()
public InputStream getInputStream() throws IOException
IOExceptionpublic int size()
public void copy(OutputStream os) throws IOException
os - IOExceptionCopyright © 2017 etc.to. All rights reserved.