Class GzipCompressorOutputStream

java.lang.Object
java.io.OutputStream
org.apache.commons.compress.compressors.CompressorOutputStream
org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class GzipCompressorOutputStream extends CompressorOutputStream
Compressed output stream using the gzip format. This implementation improves over the standard GZIPOutputStream class by allowing the configuration of the compression level and the header metadata (file name, comment, modification time, operating system and extra flags).
See Also:
  • Field Details

    • FNAME

      private static final int FNAME
      Header flag indicating a file name follows the header
      See Also:
    • FCOMMENT

      private static final int FCOMMENT
      Header flag indicating a comment follows the header
      See Also:
    • out

      private final OutputStream out
      The underlying stream
    • deflater

      private final Deflater deflater
      Deflater used to compress the data
    • deflateBuffer

      private final byte[] deflateBuffer
      The buffer receiving the compressed data from the deflater
    • closed

      private boolean closed
      Indicates if the stream has been closed
    • crc

      private final CRC32 crc
      The checksum of the uncompressed data
  • Constructor Details

    • GzipCompressorOutputStream

      public GzipCompressorOutputStream(OutputStream out) throws IOException
      Creates a gzip compressed output stream with the default parameters.
      Parameters:
      out - the stream to compress to
      Throws:
      IOException - if writing fails
    • GzipCompressorOutputStream

      public GzipCompressorOutputStream(OutputStream out, GzipParameters parameters) throws IOException
      Creates a gzip compressed output stream with the specified parameters.
      Parameters:
      out - the stream to compress to
      parameters - the parameters to use
      Throws:
      IOException - if writing fails
      Since:
      1.7
  • Method Details