Class MemoryLimitsAwareOutputStream
java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
com.itextpdf.text.pdf.MemoryLimitsAwareOutputStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
This class implements an output stream which can be used for memory limits aware decompression of pdf streams.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intThe maximum size of array to allocate.private intThe maximum size of array to allocate.Fields inherited from class ByteArrayOutputStream
buf, count -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new byte array output stream.MemoryLimitsAwareOutputStream(int size) Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes. -
Method Summary
Modifier and TypeMethodDescriptionlongGets the maximum size which can be occupied by this output stream.setMaxStreamSize(int maxStreamSize) Sets the maximum size which can be occupied by this output stream.voidwrite(byte[] b, int off, int len) Methods inherited from class ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, toString, write, writeBytes, writeToMethods inherited from class OutputStream
flush, nullOutputStream, write
-
Field Details
-
DEFAULT_MAX_STREAM_SIZE
private static final int DEFAULT_MAX_STREAM_SIZEThe maximum size of array to allocate. Attempts to allocate larger arrays will result in an exception.- See Also:
-
maxStreamSize
private int maxStreamSizeThe maximum size of array to allocate. Attempts to allocate larger arrays will result in an exception.
-
-
Constructor Details
-
MemoryLimitsAwareOutputStream
public MemoryLimitsAwareOutputStream()Creates a new byte array output stream. The buffer capacity is initially 32 bytes, though its size increases if necessary. -
MemoryLimitsAwareOutputStream
public MemoryLimitsAwareOutputStream(int size) Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.- Parameters:
size- the initial size.- Throws:
IllegalArgumentException- if size is negative.
-
-
Method Details
-
getMaxStreamSize
public long getMaxStreamSize()Gets the maximum size which can be occupied by this output stream.- Returns:
- the maximum size which can be occupied by this output stream.
-
setMaxStreamSize
Sets the maximum size which can be occupied by this output stream.- Parameters:
maxStreamSize- the maximum size which can be occupied by this output stream.- Returns:
- this
MemoryLimitsAwareOutputStream
-
write
public void write(byte[] b, int off, int len) - Overrides:
writein classByteArrayOutputStream
-