Package org.apache.fop.pdf
Class InMemoryStreamCache
- java.lang.Object
-
- org.apache.fop.pdf.InMemoryStreamCache
-
- All Implemented Interfaces:
StreamCache
public class InMemoryStreamCache extends java.lang.Object implements StreamCache
StreamCache implementation that uses temporary files rather than heap.
-
-
Constructor Summary
Constructors Constructor Description InMemoryStreamCache()Creates a new InMemoryStreamCache.InMemoryStreamCache(int hintSize)Creates a new InMemoryStreamCache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears and resets the cache.java.io.OutputStreamgetOutputStream()Get the current OutputStream.intgetSize()Returns the current size of the stream.intoutputContents(java.io.OutputStream out)Outputs the cached bytes to the given stream.voidwrite(byte[] data)Convenience method for writing data to the stream cache.
-
-
-
Method Detail
-
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.IOExceptionGet the current OutputStream. Do not store it - it may change from call to call.- Specified by:
getOutputStreamin interfaceStreamCache- Returns:
- the output stream containing the data
- Throws:
java.io.IOException- if there is an error getting the output stream
-
write
public void write(byte[] data) throws java.io.IOExceptionConvenience method for writing data to the stream cache.- Specified by:
writein interfaceStreamCache- Parameters:
data- byte array to write- Throws:
java.io.IOException- if there is an IO error
-
outputContents
public int outputContents(java.io.OutputStream out) throws java.io.IOExceptionOutputs the cached bytes to the given stream.- Specified by:
outputContentsin interfaceStreamCache- Parameters:
out- the output stream to write to- Returns:
- the number of bytes written
- Throws:
java.io.IOException- if there is an IO error writing to the output stream
-
getSize
public int getSize() throws java.io.IOExceptionReturns the current size of the stream.- Specified by:
getSizein interfaceStreamCache- Returns:
- the length of the stream
- Throws:
java.io.IOException- if there is an error getting the size
-
clear
public void clear() throws java.io.IOExceptionClears and resets the cache.- Specified by:
clearin interfaceStreamCache- Throws:
java.io.IOException- if there is an error closing the stream
-
-