Decompress a 7zip archive with multiple files & directories in Java [closed]

旧城冷巷雨未停 提交于 2019-12-10 15:58:19

问题


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.


回答1:


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.

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.

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.

Here is a java TAR library.



来源:https://stackoverflow.com/questions/3469904/decompress-a-7zip-archive-with-multiple-files-directories-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!