0

如何在 Java 中提取 XZ 文件?我有一个7z SFX带有.exe扩展名的文件,将其转换为XZ文件,但我如何最终提取其内容?

在 Windows 上,我可以轻松地单击鼠标右键,然后通过从上下文菜单中WinRAR进行选择来进行提取。Extract here

4

1 回答 1

0

试试这个

try { 
    FileInputStream fin = new FileInputStream(path + "myFile.xz");
    BufferedInputStream in = new BufferedInputStream(fin);
    FileOutputStream out = new FileOutputStream(des + "myDecompressed");
    XZInputStream xzIn = new XZInputStream(in);
    final byte[] buffer = new byte[8192];
    int n = 0;
    while (-1 != (n = xzIn.read(buffer))) {
        out.write(buffer, 0, n);
    } 
    out.close();
    xzIn.close();
}
catch(Exception e) { 
    Log.e("Decompress", "unzip", e); 
于 2016-05-05T00:12:14.943 回答