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")
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。