ZIP libraries for Java
For Java there are 3 good choices:
- java.util.zip is built into the JDK:
ZipFilefor random access,ZipInputStream/ZipOutputStreamfor streams, plus the ZIP file system provider (FileSystems.newFileSystem). Supports ZIP64, stored and DEFLATE. No encryption. - Apache Commons Compress adds Unix permissions and extra fields, more compression methods for reading (bzip2, Deflate64, legacy methods), split archives, parallel compression and control over file name encoding. Apache 2.0.
- zip4j has the simplest API (
new ZipFile("a.zip").extractAll("dir")) and supports AES and ZipCrypto encryption and split archives. Apache 2.0.
Use java.util.zip for plain archives, zip4j when you need passwords, Commons Compress when you need Unix metadata or work with other archive formats too.
- Commons Compress Apache Commons Compress reads and writes ZIP, tar, 7z and more in Java. How to extract and create ZIP files with Unix permissions, ZIP64, Zstandard.
- java.util.zip java.util.zip is the ZIP API built into the JDK. How to create and extract ZIP files, list entries, read one file and use the ZIP file system provider.
- zip4j zip4j is a Java library for ZIP files with AES encryption and a simple API. How to create password-protected ZIP files, extract all or one file, add folders.