org.apache.commons.compress.compressors.gzip

Class GzipCompressorInputStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable


    public class GzipCompressorInputStreamextends CompressorInputStream
    Input stream that decompresses .gz files. This supports decompressing concatenated .gz files which is important when decompressing standalone .gz files.

    GZIPInputStream doesn't decompress concatenated .gz files: it stops after the first member and silently ignores the rest. It doesn't leave the read position to point to the beginning of the next member, which makes it difficult workaround the lack of concatenation support.

    Instead of using GZIPInputStream, this class has its own .gz container format decoder. The actual decompression is done with Inflater.

    • Constructor Detail

      • GzipCompressorInputStream

        public GzipCompressorInputStream(InputStream inputStream)                          throws IOException
        Constructs a new input stream that decompresses gzip-compressed data from the specified input stream.

        This is equivalent to GzipCompressorInputStream(inputStream, false) and thus will not decompress concatenated .gz files.

        Parameters:
        inputStream - the InputStream from which this object should be created of
        Throws:
        IOException - if the stream could not be created
      • GzipCompressorInputStream

        public GzipCompressorInputStream(InputStream inputStream,                         boolean decompressConcatenated)                          throws IOException
        Constructs a new input stream that decompresses gzip-compressed data from the specified input stream.

        If decompressConcatenated is false: This decompressor might read more input than it will actually use. If inputStream supports mark and reset, then the input position will be adjusted so that it is right after the last byte of the compressed stream. If mark isn't supported, the input position will be undefined.

        Parameters:
        inputStream - the InputStream from which this object should be created of
        decompressConcatenated - if true, decompress until the end of the input; if false, stop after the first .gz member
        Throws:
        IOException - if the stream could not be created
    • Method Detail

      • getMetaData

        public GzipParameters getMetaData()
        Provides the stream's meta data - may change with each stream when decompressing concatenated streams.
        Returns:
        the stream's meta data
        Since:
        1.8
      • matches

        public static boolean matches(byte[] signature,              int length)
        Checks if the signature matches what is expected for a .gz file.
        Parameters:
        signature - the bytes to check
        length - the number of bytes to check
        Returns:
        true if this is a .gz stream, false otherwise
        Since:
        1.1

Copyright © 2016 The Apache Software Foundation. All rights reserved.



NOTHING
NOTHING
Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14