[Java] Introducing "ZT Zip", a utility that can handle ZIP files very easily

I found a library that can operate a ZIP file with just one line of code, so I will introduce it.

Library introduction (Maven or Gradle)

If you are familiar with Java, you probably know it, so I won't explain it in detail.


<!-- https://mvnrepository.com/artifact/org.zeroturnaround/zt-zip -->


// https://mvnrepository.com/artifact/org.zeroturnaround/zt-zip
compile group: 'org.zeroturnaround', name: 'zt-zip', version: '1.13'

Sample code

Here are some codes that you will use often. Since it is implemented by the static method, you can write each in just one line.

ZipUtil.unpack(new File("C:/work/file.zip"), new File("C:/work/unzip/"));

ZipUtil.pack(new File("C:/work/unzip/"), new File("C:/work/file.zip"));

//Replace the files in the ZIP
boolean successFlg = ZipUtil.replaceEntry(new File("C:/work/file.zip"),
        "/config/production.properties", new File("C:/work/production.properties"));

//Add files into ZIP
ZipUtil.addEntry(new File("C:/work/file.zip"), "/config/develop.properties", new File("C:/work/develop.properties"), new File("C:/work/file_dst.zip"));

If you want to know more ...

Let's see the official documentation ... Written in simple English. zeroturnaround/zt-zip: ZeroTurnaround ZIP Library

Recommended Posts

[Java] Introducing "ZT Zip", a utility that can handle ZIP files very easily
[JavaScript] Java programmers! You can understand JavaScript closures very easily!
Write a class that can be ordered in Java
Problems that can easily be mistaken for Java and JavaScript
Let's touch on Deep Java Library (DJL), a library that can handle Deep Learning in Java released from AWS.