Class DeflaterOutputStream

All Implemented Interfaces:
IFinishable, Closeable, Flushable, AutoCloseable

public class DeflaterOutputStream extends DeflaterOutputStream implements IFinishable
An output stream that compresses data using the DEFLATE compression algorithm. This is a wrapper around DeflaterOutputStream that provides convenient constructors for specifying compression level and buffer size.

The compression level can be set to values between 0 (no compression) and 9 (maximum compression), or use -1 for the default compression level.

  • Constructor Details

    • DeflaterOutputStream

      public DeflaterOutputStream (OutputStream out, int level, int size)
      Creates a new deflater output stream with a specified compression level and buffer size.
      Parameters:
      out - the output stream to write compressed data to
      level - the compression level (0-9, or -1 for default)
      size - the buffer size in bytes
    • DeflaterOutputStream

      public DeflaterOutputStream (OutputStream out, int level)
      Creates a new deflater output stream with a specified compression level and default buffer size.
      Parameters:
      out - the output stream to write compressed data to
      level - the compression level (0-9, or -1 for default)
    • DeflaterOutputStream

      public DeflaterOutputStream (OutputStream out)
      Creates a new deflater output stream with default compression level and buffer size.
      Parameters:
      out - the output stream to write compressed data to
  • Method Details

    • close

      public void close() throws IOException
      Closes this output stream and releases any system resources associated with it. This method finishes writing compressed data to the output stream before closing.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class DeflaterOutputStream
      Throws:
      IOException - if an I/O error occurs
    • finish

      public void finish() throws IOException
      Finishes writing compressed data to the output stream without closing the underlying stream. This method completes the compression process and ends the deflater, releasing its resources.
      Specified by:
      finish in interface IFinishable
      Overrides:
      finish in class DeflaterOutputStream
      Throws:
      IOException - if an I/O error occurs