Package org.apache.commons.compress.compressors.gzip

# Class GzipCompressorOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.commons.compress.compressors.CompressorOutputStream<OutputStream>
org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`

public class GzipCompressorOutputStream extends CompressorOutputStream<OutputStream>
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:
  - GZIP File Format Specification

- ## Field Summary

  ### Fields inherited from class java.io.FilterOutputStream

  `out`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GzipCompressorOutputStream(OutputStream out)`
  Creates a gzip compressed output stream with the default parameters.
  `GzipCompressorOutputStream(OutputStream out, GzipParameters parameters)`
  Creates a gzip compressed output stream with the specified parameters.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `void`
  `finish()`
  Finishes writing compressed data to the underlying stream without closing it.
  `void`
  `write(byte[] buffer)`
  `void`
  `write(byte[] buffer, int offset, int length)`
  `void`
  `write(int b)`

  ### Methods inherited from class org.apache.commons.compress.compressors.CompressorOutputStream

  `out`

  ### Methods inherited from class java.io.FilterOutputStream

  `flush`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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

  - ### close

    public void close() throws IOException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Overrides:
      `close` in class `FilterOutputStream`
    Throws:
      `IOException`

  - ### finish

    public void finish() throws IOException
    Finishes writing compressed data to the underlying stream without closing it.
    Throws:
      `IOException` - on error
    Since:
      1.7

  - ### write

    public void write(byte[] buffer) throws IOException
    Overrides:
      `write` in class `FilterOutputStream`
    Throws:
      `IOException`
    Since:
      1.1

  - ### write

    public void write(byte[] buffer, int offset, int length) throws IOException
    Overrides:
      `write` in class `FilterOutputStream`
    Throws:
      `IOException`
    Since:
      1.1

  - ### write

    public void write(int b) throws IOException
    Overrides:
      `write` in class `FilterOutputStream`
    Throws:
      `IOException`