简体   繁体   中英

Storing a folder in a file with java

What would be the easier and safer way in JAVA to store a folder in a single file like zip, tar, rar, iso, etc? something like compressing and decompressing it. I don't really need compression, just putting the whole folder in a single file

I'm looking for a library that allows me to simply give it the path to the folder and obtain the file and the reverse process.

Thanks!

Check out ZT-Zip on GitHub.

Compress a directory into a ZIP archive

ZipUtil.pack(new File("/tmp/demo"), new File("/tmp/demo.zip"));

Extract a ZIP archive

ZipUtil.unpack(new File("/tmp/demo.zip"), new File("/tmp/demo"));

The library supports a lot of other cool operations as well, including existence checking , extracting a subset of a zip archive and comparing zip archives.

Check out the Readme

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM