我在 unix 机器上有一个 .Z 文件。有什么方法可以从 java 调用 unix 解压缩命令吗?
最佳答案
我还面临解压缩 .Z 文件的需要,通过互联网查看但没有找到比下面我的更好的答案。可以使用 Apache Commons Compress
FileInputStream fin = new FileInputStream("archive.tar.Z");
BufferedInputStream in = new BufferedInputStream(fin);
FileOutputStream out = new FileOutputStream("archive.tar");
ZCompressorInputStream zIn = new ZCompressorInputStream(in);
final byte[] buffer = new byte[buffersize];
int n = 0;
while (-1 != (n = zIn.read(buffer))) {
out.write(buffer, 0, n);
}
out.close();
zIn.close();
这真的很有效
关于java - 使用java在unix中解压缩.Z文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22712100/