|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
com.google.common.io.FileBackedOutputStream
@Beta public final class FileBackedOutputStream
An OutputStream
that starts buffering to a byte array, but
switches to file buffering once the data reaches a configurable size.
This class is thread-safe.
Constructor Summary | |
---|---|
FileBackedOutputStream(int fileThreshold)
Creates a new instance that uses the given file threshold. |
|
FileBackedOutputStream(int fileThreshold,
boolean resetOnFinalize)
Creates a new instance that uses the given file threshold, and optionally resets the data when the InputSupplier returned
by getSupplier() is finalized. |
Method Summary | |
---|---|
void |
close()
|
void |
flush()
|
InputSupplier<java.io.InputStream> |
getSupplier()
Returns a supplier that may be used to retrieve the data buffered by this stream. |
void |
reset()
Calls close() if not already closed, and then resets this
object back to its initial state, for reuse. |
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileBackedOutputStream(int fileThreshold)
ThresholdOutputStream(fileThreshold, false)
.
fileThreshold
- the number of bytes before the stream should
switch to buffering to a filepublic FileBackedOutputStream(int fileThreshold, boolean resetOnFinalize)
InputSupplier
returned
by getSupplier()
is finalized.
fileThreshold
- the number of bytes before the stream should
switch to buffering to a fileresetOnFinalize
- if true, the reset()
method will
be called when the InputSupplier
returned by getSupplier()
is finalizedMethod Detail |
---|
public InputSupplier<java.io.InputStream> getSupplier()
public void reset() throws java.io.IOException
close()
if not already closed, and then resets this
object back to its initial state, for reuse. If data was buffered
to a file, it will be deleted.
java.io.IOException
- if an I/O error occurred while deleting the file bufferpublic void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.OutputStream
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |