public class DeferredByteOutputStream
extends org.apache.commons.io.output.ThresholdingOutputStream
开发人员: renhui
开发时间: 2014-1-2
Constructor and Description |
---|
DeferredByteOutputStream(int threshold)
Constructs an instance of this class which will trigger an event at the
specified threshold, and save data to a file beyond that point.
|
Modifier and Type | Method and Description |
---|---|
void |
clearData() |
void |
close()
Closes underlying output stream, and mark this as closed
|
byte[] |
getFileData()
返回文件字节流
|
byte[] |
getMemoryData()
Returns the data for this output stream as an array of bytes, assuming
that the data has been retained in memory.
|
protected OutputStream |
getStream()
Returns the current output stream.
|
boolean |
isInMemory()
Determines whether or not the data for this output stream has been
retained in memory.
|
protected void |
thresholdReached()
Switches the underlying output stream from a memory based stream to one
that is backed by disk.
|
void |
writeTo(OutputStream out)
Writes the data from this output stream to the specified output stream,
after it has been closed.
|
public DeferredByteOutputStream(int threshold)
threshold
- The number of bytes at which to trigger an event.outputFile
- The file to which data is saved beyond the threshold.protected OutputStream getStream() throws IOException
getStream
in class org.apache.commons.io.output.ThresholdingOutputStream
IOException
- if an error occurs.protected void thresholdReached() throws IOException
thresholdReached
in class org.apache.commons.io.output.ThresholdingOutputStream
IOException
- if an error occurs.public boolean isInMemory()
true
if the data is available in memory; false
otherwise.public byte[] getMemoryData()
null
.null
if no such data
is available.public byte[] getFileData()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class org.apache.commons.io.output.ThresholdingOutputStream
IOException
- if an error occurs.public void writeTo(OutputStream out) throws IOException
out
- output stream to write to.IOException
- if this stream is not yet closed or an error occurs.public void clearData()
Copyright © 2006–2018 TinyGroup. All rights reserved.