Package dk.netarkivet.common.utils
Class LargeFileGZIPInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.util.zip.InflaterInputStream
-
- java.util.zip.GZIPInputStream
-
- dk.netarkivet.common.utils.LargeFileGZIPInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class LargeFileGZIPInputStream extends java.util.zip.GZIPInputStream
Subclass of GZIPInputstream, including a workaround to support >2GB files.Java currently has a bug that does not allow unzipping Gzip files with contents larger than 2GB. The result will be an IOException with the message "Corrupt GZIP trailer". This class works around that bug by ignoring that message for all streams which are uncompressed larger than 2GB. This sacrifices CRC checks for those streams, though.
See sun bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5092263
- See Also:
GZIPInputStream
-
-
Constructor Summary
Constructors Constructor Description LargeFileGZIPInputStream(java.io.InputStream in)
Creates a new input stream with a default buffer size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
read(byte[] buf, int off, int len)
Reads uncompressed data into an array of bytes.-
Methods inherited from class java.util.zip.InflaterInputStream
available, fill, mark, markSupported, read, reset, skip
-
-
-
-
Constructor Detail
-
LargeFileGZIPInputStream
public LargeFileGZIPInputStream(java.io.InputStream in) throws java.io.IOException
Creates a new input stream with a default buffer size.- Parameters:
in
- the input stream- Throws:
java.io.IOException
- if an I/O error has occurred. Note: We usually don't allow IOException in our code, but this is done here to closely mimic GZIPInputStream
-
-
Method Detail
-
read
public int read(byte[] buf, int off, int len) throws java.io.IOException
Reads uncompressed data into an array of bytes. Blocks until enough input is available for decompression.- Overrides:
read
in classjava.util.zip.GZIPInputStream
- Parameters:
buf
- the buffer into which the data is readoff
- the start offset of the datalen
- the maximum number of bytes read- Returns:
- the actual number of bytes read, or -1 if the end of the compressed input stream is reached
- Throws:
java.io.IOException
- if an I/O error has occurred or the compressed input data is corrupt. Note that size differences are ignored in this workaround class if size is larger than Integer.MAX_VALUE. Note: We usually don't allow IOException in our code, but this is done here to closely mimic GZIPInputStream
-
-