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 文件
基础教程推荐
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
