1

Recently, when working on an Android project, I encountered a need to download a zip file and decompress it. For ordinary file decompression, OutputStream and InputStream can be used to complete it. However, if you need a password or something when decompressing, ordinary stream reading will not work. Finally, after searching for a long time, I found an open source library of ZIP4J. ZIP4J supports the following features:

  • Create, Add, Extract, Update, Remove files from a Zip file
  • Read/Write password protected Zip files
  • AES 128/256 Encryption/Decryption
  • Standard Zip Encryption/Decryption
  • Zip64 format
  • Store (No Compression) and Deflate compression method
  • Create or extract files from Split Zip files (Ex: z01, z02,...zip)
  • Unicode file names
  • Progress Monitor

在这里插入图片描述
Next, we downloaded the source code on Git. Since it is an Android project, I want to make the code a local dependency. The most direct way is to package it into a jar package. Use IntellJ Ideal to open the project source code, and the next step is to compile the source code into a jar package.

First, in the project Maven Projects interface, click on the project to be packaged, and perform the following 4 steps.

在这里插入图片描述
After the installation is complete, the relevant information of the jar will be output in the console, as shown below.
在这里插入图片描述
We can go to the corresponding directory to view the generated jar package. In order to verify whether the jar package is successful, we can use the decompression software to view it.

In addition, we can also convert Maven dependencies into Gradle dependencies, such as:

 // Maven依赖
<dependency>
    <groupId>net.lingala.zip4j</groupId>
    <artifactId>zip4j</artifactId>
    <version>2.10.0</version>
</dependency>

//Gradle依赖
implementation("net.lingala.zip4j:zip4j:2.10.0")

xiangzhihong
5.9k 声望15.3k 粉丝

著有《React Native移动开发实战》1,2,3、《Kotlin入门与实战》《Weex跨平台开发实战》、《Flutter跨平台开发与实战》1,2和《Android应用开发实战》