Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java library to work with Zip files [closed]

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?

like image 731
Ariyan Avatar asked Mar 19 '11 13:03

Ariyan


2 Answers

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

like image 53
Colin Goudie Avatar answered Oct 24 '22 23:10

Colin Goudie


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.

like image 39
Alnitak Avatar answered Oct 24 '22 23:10

Alnitak