How to use zip4j to extract an zip file with password protection(如何使用 zip4j 提取具有密码保护的 zip 文件)
问题描述
我正在尝试解压缩带有密码保护的 zip 文件.我知道有一个名为zip4j"的 java 库可以帮助我.但是我无法打开 zip4j 网站来查看教程.
I am trying to unzip a zipfile with password protection. I know there is a java library named "zip4j" that could help me. But I am failing to open the zip4j website to see the tutorial.
我已经用另一个镜像下载了 zip4j 库,但我不知道如何使用它.有没有人可以粘贴使用 zip4j 解压缩密码保护 zip 文件的示例代码?
I had download zip4j library with another mirror but I don't know how to use it. Is there anyone that could paste example code for using zip4j unzip password protection zip file?
zip4j 网站
非常感谢!
推荐答案
尝试以下操作并确保您使用的是最新的 Zip4j 库 (1.3.1):
Try the following and make sure you are using the most recent Zip4j library (1.3.1):
String source = "folder/source.zip";
String destination = "folder/source/";
String password = "password";
try {
ZipFile zipFile = new ZipFile(source);
if (zipFile.isEncrypted()) {
zipFile.setPassword(password);
}
zipFile.extractAll(destination);
} catch (ZipException e) {
e.printStackTrace();
}
这篇关于如何使用 zip4j 提取具有密码保护的 zip 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 zip4j 提取具有密码保护的 zip 文件


基础教程推荐
- 多个组件的复杂布局 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- Java Swing计时器未清除 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 从 python 访问 JVM 2022-01-01