解压缩包含多个文件的

解压缩包含多个文件的

本文介绍了解压缩包含多个文件的 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 File("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中的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 13:53