java.lang.Object
java.io.OutputStream
org.apache.commons.io.output.ThresholdingOutputStream
org.apache.commons.io.output.DeferredFileOutputStream
org.codelibs.curl.io.ContentOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
public class ContentOutputStream
extends org.apache.commons.io.output.DeferredFileOutputStream
ContentOutputStream is a custom output stream that extends DeferredFileOutputStream.
It writes data to a temporary file once the data size exceeds a specified threshold.
This class ensures that the temporary file is deleted if it is not needed. It uses a logger to log warnings if there are issues deleting the temporary file.
Fields:
logger- Logger instance for logging warnings.PREFIX- Prefix for the temporary file name.SUFFIX- Suffix for the temporary file name.done- Flag indicating whether the file has been retrieved.
Constructors:
ContentOutputStream(int threshold, File tmpDir)- Constructs a ContentOutputStream with a specified threshold and temporary directory.
Methods:
getFile()- Marks the file as retrieved and returns the file.close()- Closes the stream and deletes the temporary file if it is not needed.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.io.output.DeferredFileOutputStream
org.apache.commons.io.output.DeferredFileOutputStream.Builder -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.commons.io.output.DeferredFileOutputStream
builder, getData, getPath, getStream, isInMemory, thresholdReached, toInputStream, writeToMethods inherited from class org.apache.commons.io.output.ThresholdingOutputStream
checkThreshold, flush, getByteCount, getOutputStream, getThreshold, isThresholdExceeded, resetByteCount, setByteCount, write, write, writeMethods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
logger
-
PREFIX
- See Also:
-
SUFFIX
- See Also:
-
done
protected boolean done
-
-
Constructor Details
-
ContentOutputStream
-
-
Method Details
-
getFile
- Overrides:
getFilein classorg.apache.commons.io.output.DeferredFileOutputStream
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classorg.apache.commons.io.output.DeferredFileOutputStream- Throws:
IOException
-