Decompressing a Gzip Archive in Java

I am trying to unzip about 8000 gzip files in Java. My first attempt was to use GZIPInputStream, but the performance was terrible.

Does anyone know of any alternative to unpacking gzip archives? I tried ZipInputStream but did not recognize the gzip format.

Thanks in advance.

+5
source share
3 answers

You need to use buffering. Writing small pieces of data will be inefficient. Implementation of compression in native code in the Sun JDK. Even if not for buffered performance, it usually exceeded a reasonable file or network I / O.

OutputStream out = new BufferedOutputStream(new GZIPOutputStream(rawOut));

InputStream in = new BufferedInputStream(new GZIPInputStream(rawIn));

/, , ( ) . , "Deflaters" .

ZipInputStream , .

+8

, GZipInputStream , ? , -? , ? , , .

, GZipInputStream, , , , . ( ). , I/O, , , .

+4

For this scale, you may want to switch to your native language if your platform requirements are limited. You can use JNI to invoke the library or invoke your own command with ProcessBuilder.

-2
source

All Articles