我可以解压缩zip、gzip和rar文件,但我还需要解压缩bzip2文件以及对它们进行存档(.tar)。我还没有遇到一个好的库来使用。
我将Java与Maven一起使用,所以理想情况下,我希望将其作为依赖项包含在POM中。
你推荐哪些库?
发布于 2010-02-24 09:01:09
我所能看到的最好的选择是带有这个Maven依赖项的Apache Commons Compress。
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.0</version>
</dependency>FileInputStream in =新的FileInputStream("archive.tar.bz2");FileOutputStream out =新的FileOutputStream("archive.tar");BZip2CompressorInputStream bzIn =新的BZip2CompressorInputStream(in);最终的byte[]缓冲区=新的字节缓冲区大小;int n= 0;while (-1 != (n =bzIn.read(缓冲区){ out.write( buffer,0,n);} out.close();bzIn.close();
https://stackoverflow.com/questions/2322944
复制相似问题