File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Better ZIP libarary for Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Better ZIP libarary for Java" Watch "Better ZIP libarary for Java" New topic

Better ZIP libarary for Java

Tom Malia

Joined: Aug 05, 2009
Posts: 22
I'm trying to read the file lists (names, paths, CRC, etc.) for ZIP files that were created with WinZIP and 7ZIP. Many of the archive files are over 4 gigs and many of the files in the archive files are over 4 gigs. The ZipFile and ZipInputStream class in the standard Util library are NOT working.

I've been searching everywhere to try to find an alternative library that properly supports ZIP64 etc. and I just can't believe what I'm seeing! I can't find anything anywhere. Well, except for some .NET library that hase a Java wapper will only work on Win32 OS.

How can there be such a gaping hole in the support of archive files in Java!?!?!

Does anyone know where I can get a GOOD ZIP library for Java? At a minimum I need to be able to reliably read the list of contained files and directories for Archive files greater than 4 gigs and with files inside that are larger than 4 gigs. Ideally, I'd also like support for foreign characters in the file names.

Is there REALLY no support out there?!?!? What the heck are other people doing who need to read these ZIP files from within Java?

Thanks in advance.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
An alternative ZIP implementation can be found at; not sure if it meets your requirements though.
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

And you can always use Runtime.exec() or ProcessBuilder to execute the native platform zip/7zip/bzip/rar/etc program. When running external programs, be aware of when Runtime.exec() won't.

[How To Ask Questions On JavaRanch]
Tom Malia

Joined: Aug 05, 2009
Posts: 22
Thanks for the suggestions.

I tried the apache libraries and they had all the same problems with large zip files. Also, I eventually found out that part of the problem was non-standard characters in some of the file names in the zip files.

As for using an external application, I'm not sure if this would have work for what I needed or not. I didn't need to actually compress or extract anything. I just needed to get the information for all contained files (names, sizes, cRC codes, etc.) and then process that data. I'm not sure what external programs would have given me this data in a format that would be easy to cycle through.

In the end, someone on the Sun discussion forum suggested that i use the pre-release version of JDK 7 which has support for large zip files and adds support for defining the character set that should be used when processing zip files. This ended up being a viable solution so far.

An interesting issue I found though.... Originally my code used Generics so that I could use the "for(ZipEntry ze ; zipfileList)" kind of code. This had a major problem. Using this structure, the code crashes when you first try to build the List if there is a single file in the collection has a character that can't be converted. I had to use the standard enumeration method method which allowed me to catch errors from unconvertible characters in a given file but still be able to process the other files.
I agree. Here's the link:
subject: Better ZIP libarary for Java
It's not a secret anymore!