Compressing & Decompressing 7z file in java

Deadly 提交于 2020-01-10 17:30:49

问题


I want to compress a file into zip, rar and 7z format using java code. Also I want to decompress these files at a specified location. Can anyone please tell me how to compress and decompress files using 7-zip in java?


回答1:


I have used : sevenzipjbinding.jar sevenzipjbinding-Allplatforms.jar

I am now able to decompress files using these jars.

Try this link for decompression: http://sourceforge.net/projects/sevenzipjbind/forums/forum/757964/topic/3844899




回答2:


SevenZipBinding is great for decompression, it even detects format automaticaly. Problem is it can't compress. You can create zip archives using ZIP4J. It however offers only plain zip. LZMA apparently can compress single files into 7z archives, but I haven't tried it yet.




回答3:


You can also write a batch script or just inline command execution which you call from java to extract and compress. Note that this option is for windows platforms only and required a few admin skills. 7zip provides an exe file to facilitate this. I have used this for one of my utility and worked perfectly. If you are interested I can send u the code.



来源:https://stackoverflow.com/questions/12781207/compressing-decompressing-7z-file-in-java

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