Class MemoryLimitsAwareOutputStream

java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
com.itextpdf.kernel.pdf.MemoryLimitsAwareOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

class MemoryLimitsAwareOutputStream extends ByteArrayOutputStream
This class implements an output stream which can be used for memory limits aware decompression of pdf streams.
  • Field Details

    • 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:
    • maxStreamSize

      private int maxStreamSize
      The 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

      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 class ByteArrayOutputStream