解压缩具有多个文件的7zip存档文件; Java中的目录 [英] Decompress a 7zip archive with multiple files & directories in Java

查看:163
本文介绍了解压缩具有多个文件的7zip存档文件; Java中的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想解压缩具有多个文件的7zip / lzma存档, Java中的目录。我尝试使用官方的7zip SDK,但由于我的编程技能没有达到该主题的高级水平,因此我失败了。
但是,我喜欢使用一些库来简化Java支持,例如LzmaOutputStream / LzmaInputStream-但是我不知道如何使用这些流来解压缩多文件存档。

I want to decompress a 7zip/lzma archive with multiple files & directories in Java. I tried to use the official 7zip SDK, but I failed, as my programming skills are not that advanced for this subject. However I fonud some libraries which make the support in Java easier, speaking of LzmaOutputStream/LzmaInputStream - However I don't know how to use those "streams" to decompress a multi-file archive. I am stuck.

推荐答案

在示例中,将 compressed 替换为new文件( PATH_TO_FILE)。该示例代码将产生一个输出流,我想LzmaOutputStream或该库具有将流转换为二进制或字符串的适当方法。

In the example, replace compressed with new File("PATH_TO_FILE"). The example code will yield an output stream, I suppose the LzmaOutputStream or the library has appropriate methods for converting the stream to binary or string.

默认情况下,Lzma只是一种压缩算法,而不是像tar或zip这样的文件存档器。 (注意:7-Zip程序是一个文件存档器,但是链接到的库不支持文件遍历和解压缩。

By default Lzma is only a compression algorithm, not a file archiver like tar or zip. (Note: The 7-Zip program is a file archiver, but the library you linked to does not support file traversal and unpacking.

我建议使用一个良好的支持程序压缩算法,例如Zip或gz。如果必须使用lzma,则可以使用tar来构建文件存档,然后使用lzma对其进行压缩;或者使用压缩率为零的zip。

I would suggest using a well-supporter compression algorithm like Zip or gz. If you must use lzma you could use tar to build a file archive and then compress it with lzma. Or use zip with zero compression.

这是一个 java TAR库

这篇关于解压缩具有多个文件的7zip存档文件; Java中的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆