Class GzipCompressorOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class GzipCompressorOutputStream
    extends CompressorOutputStream<java.io.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:
    RFC 1952 GZIP File Format Specification
    • Field Summary

      • Fields inherited from class java.io.FilterOutputStream

        out
    • Constructor Summary

      Constructors 
      Constructor Description
      GzipCompressorOutputStream​(java.io.OutputStream out)
      Creates a gzip compressed output stream with the default parameters.
      GzipCompressorOutputStream​(java.io.OutputStream out, GzipParameters parameters)
      Creates a gzip compressed output stream with the specified parameters.
    • Constructor Detail

      • GzipCompressorOutputStream

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

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

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class CompressFilterOutputStream<java.io.OutputStream>
        Throws:
        java.io.IOException
      • finish

        public void finish()
                    throws java.io.IOException
        Finishes writing compressed data to the underlying stream without closing it.
        Overrides:
        finish in class CompressFilterOutputStream<java.io.OutputStream>
        Throws:
        java.io.IOException - on error
        Since:
        1.7
      • write

        public void write​(byte[] buffer)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
        Since:
        1.1
      • write

        public void write​(byte[] buffer,
                          int offset,
                          int length)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
        Since:
        1.1
      • write

        public void write​(int b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException