我所看到的最好的选择是具有此Maven依赖项的Apache Commons
Compress。
<dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-compress</artifactId> <version>1.0</version></dependency>
从示例:
FileInputStream in = new FileInputStream("archive.tar.bz2");FileOutputStream out = new FileOutputStream("archive.tar");BZip2CompressorInputStream bzIn = new BZip2CompressorInputStream(in);final byte[] buffer = new byte[buffersize];int n = 0;while (-1 != (n = bzIn.read(buffer))) { out.write(buffer, 0, n);}out.close();bzIn.close();



