I need to create a zip file from my java program.
I need a library that be able to create zip files and store entries from text and file in it and the most important thing is i need it be able to store entire directory in it (A directory with several levels of other directories that each have some files in them).
Can you suggest me one?
Check out Zip4j - http://www.lingala.net/zip4j/
I've ran into this problem today and I refuse to do such low level crap that the JDK wants us to do. Hopefully this little library will work
A library for doing the hard part of handling Zip files (i.e. the compression) is built right in to Java SE (java.util.zip
):
http://download.oracle.com/javase/1.5.0/docs/api/java/util/zip/package-summary.html
For your higher level functions it wouldn't be that hard to write some functions to recursively traverse a directory and copy the files into a ZipOutputStream
- probably less than 50 lines of code or so.
There's a good example at http://www.javareference.com/jrexamples/viewexample.jsp?id=108 - it needs a little bit of work to do single files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With