Package com.oss.util

Class CompressOutputStream

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class CompressOutputStream extends DeflaterOutputStream
This class extends CompressOutputStream and facilitates temporary in-memory buffering of encoding. The buffering is used to insert compression prefix before encoding prior to writing them to a target output stream.
Since:
ASN.1/Java 5.1.0
  • Constructor Details

    • CompressOutputStream

      public CompressOutputStream(OutputStream out)
      Constructs CompressOutputStream with a default compressor and buffer size.
      Parameters:
      out - the output stream
    • CompressOutputStream

      public CompressOutputStream(OutputStream out, Deflater deflater)
      Constructs CompressOutputStream with the specified compressor and a default buffer size.
      Parameters:
      out - the output stream
      deflater - the compressor ("deflater")
    • CompressOutputStream

      public CompressOutputStream(OutputStream out, Deflater deflater, int size)
      Constructs CompressOutputStream with the specified compressor and buffer size.
      Parameters:
      out - the output stream
      deflater - the compressor ("deflater")
      size - the output buffer size
      Throws:
      IllegalArgumentException - if size is <= 0 Constructs CompressOutputStream and attaches it to sink. Additionally specifies the initial capacity of the internal buffer and size increment to expand the buffer when its capacity is exhausted.
  • Method Details

    • write

      public void write(byte[] b, int off, int len) throws IOException
      Writes an array of bytes to the compressed output stream. This method will block until all the bytes are written.
      Overrides:
      write in class DeflaterOutputStream
      Parameters:
      b - the data to be written
      off - the start offset of the data
      len - the length of the data
      Throws:
      IOException - if an I/O error has occurred
    • finish

      public void finish() throws IOException
      Finishes writing compressed data to the output stream without closing the underlying stream. Use this method when applying multiple filters in succession to the same output stream.
      Overrides:
      finish in class DeflaterOutputStream
      Throws:
      IOException - if an I/O error has occurred