ZIP - convenience methods
Continuous Integration
Quick Overview
The project was started and coded by Rein Raudjärv when he needed to process a large set of large ZIP archives for LiveRebel internals. Soon after we started using the utility in other projects because of the ease of use and it just worked.
The project is built using java.util.zip.* packages for stream based access. Most convenience methods for filesystem usage is also supported.
Installation
The project artifacts are available in Maven Central Repository. To include it in your maven project then you have to specify the dependency.
...
org.zeroturnaround
zt-zip
1.10
jar
...
Notice that 1.8 is the last Java 1.4 compatible release. Since then Java 1.5 is required.
Background
We had the following functional requirements:
pack and unpack directories recursively
include/exclude entries
rename entries
packing/unpacking in place - ZIP becomes directory and vice versa
iterate through ZIP entries
add or replace entries from files or byte arrays
transform ZIP entries
compare two archives - compare all entries ignoring time stamps
and these non-functional requirements:
use existing APIs as much as possible
be simple to use
be effective to use - do not traverse an entire ZIP file if only a single entry is needed
be safe to use - do not enable user to leave streams open and keep files locked
do not declare exceptions
be compatible with Java 1.5
Examples
Unpacking
Check if an entry exists in a ZIP archive
boolean exists = ZipUtil.containsEntry(new File("/tmp/demo"), "foo.txt");
Extrac