Class InMemoryOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.commons.io.output.ThresholdingOutputStream
-
- com.aspectran.web.support.multipart.inmemory.InMemoryOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class InMemoryOutputStream extends org.apache.commons.io.output.ThresholdingOutputStreamAn output stream which will retain data in memory (always).
-
-
Constructor Summary
Constructors Constructor Description InMemoryOutputStream(long threshold)Constructs an instance of this class which will trigger throw UnsupportedOperationException if the specified threshold is reached.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes underlying output stream, and mark this as closedbyte[]getData()Returns the data for this output stream as an array of bytes.protected java.io.OutputStreamgetStream()Returns the current output stream.booleanisInMemory()Determines whether or not the data for this output stream has been retained in memory.protected voidthresholdReached()Not possible in GAE.voidwriteTo(java.io.OutputStream out)Writes the data from this output stream to the specified output stream, after it has been closed.
-
-
-
Method Detail
-
getStream
protected java.io.OutputStream getStream() throws java.io.IOExceptionReturns the current output stream. This may be memory based or disk based, depending on the current state with respect to the threshold.- Specified by:
getStreamin classorg.apache.commons.io.output.ThresholdingOutputStream- Returns:
- the underlying output stream
- Throws:
java.io.IOException- if an error occurs
-
thresholdReached
protected void thresholdReached()
Not possible in GAE. Will never reach!! If it happens, try changing max upload size setting.- Specified by:
thresholdReachedin classorg.apache.commons.io.output.ThresholdingOutputStream
-
isInMemory
public boolean isInMemory()
Determines whether or not the data for this output stream has been retained in memory.- Returns:
- always
true
-
getData
public byte[] getData()
Returns the data for this output stream as an array of bytes.- Returns:
- the data for this output stream, or
nullif no such data is available
-
close
public void close() throws java.io.IOExceptionCloses underlying output stream, and mark this as closed- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classorg.apache.commons.io.output.ThresholdingOutputStream- Throws:
java.io.IOException- if an error occurs
-
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOExceptionWrites the data from this output stream to the specified output stream, after it has been closed.- Parameters:
out- output stream to write to- Throws:
java.io.IOException- if this stream is not yet closed or an error occurs
-
-