Package com.itextpdf.text.pdf
Class MemoryLimitsAwareOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.ByteArrayOutputStream
-
- com.itextpdf.text.pdf.MemoryLimitsAwareOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
class MemoryLimitsAwareOutputStream extends java.io.ByteArrayOutputStream
This class implements an output stream which can be used for memory limits aware decompression of pdf streams.
-
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_MAX_STREAM_SIZE
The maximum size of array to allocate.private int
maxStreamSize
The maximum size of array to allocate.
-
Constructor Summary
Constructors Constructor Description MemoryLimitsAwareOutputStream()
Creates 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getMaxStreamSize()
Gets the maximum size which can be occupied by this output stream.MemoryLimitsAwareOutputStream
setMaxStreamSize(int maxStreamSize)
Sets the maximum size which can be occupied by this output stream.void
write(byte[] b, int off, int len)
-
-
-
Field Detail
-
DEFAULT_MAX_STREAM_SIZE
private static final int DEFAULT_MAX_STREAM_SIZE
The maximum size of array to allocate. Attempts to allocate larger arrays will result in an exception.- See Also:
- Constant Field Values
-
maxStreamSize
private int maxStreamSize
The maximum size of array to allocate. Attempts to allocate larger arrays will result in an exception.
-
-
Constructor Detail
-
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:
java.lang.IllegalArgumentException
- if size is negative.
-
-
Method Detail
-
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
public MemoryLimitsAwareOutputStream setMaxStreamSize(int maxStreamSize)
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:
write
in classjava.io.ByteArrayOutputStream
-
-