In this post, I will show you how to unzip a .zip-file in java.
First, add the Maven dependency:
1 2 3 4 5 |
<dependency> <groupId>org.apache.ant</groupId> <artifactId>ant-compress</artifactId> <version>1.4</version> </dependency> |
Then, you need to add the following code to your method where you want to unzip.
1 2 3 4 5 6 7 8 |
Unzip unzipper = new Unzip(); try { unzipper.setSrc(new File("test.zip")); unzipper.setDest("/myFolderToExtract"); unzipper.execute(); } catch (IOException e) { e.printStackTrace(); } |