Package com.oss.util

Class CompressOutputStream

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class CompressOutputStream extends DeflaterOutputStream
  • Constructor Details

    • CompressOutputStream

      public CompressOutputStream(OutputStream out)
    • 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)
  • 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