gpt4 book ai didi

java - Zip extractAll 未定义?

转载 作者:太空宇宙 更新时间:2023-11-04 07:11:42 24 4
gpt4 key购买 nike

我正在尝试使用 Java 解压缩此文件。我找到了本指南:What is a good Java library to zip/unzip files?但我收到错误:对于 ZipFile 类型,方法 extractAll(String) 未定义

代码:

String dir = System.getProperty(user.dir);
String source = dir+"/file.zip";
String destination = dir;

try {
ZipFile zipFile = new ZipFile(source);
zipFile.extractAll(destination);
} catch (ZipException e) {
e.printStackTrace();
}

编辑:我找到了解决方案。有点尴尬,不过我导入错了-.-

最佳答案

确保您拥有正确的 jar http://www.lingala.net/zip4j/download.php

我刚刚提取了 jar,ZipFile.class 中有一个方法

  public void extractAll(String destPath)
throws ZipException
{
extractAll(destPath, null);
}

因此,请检查您是否已从正确的 jar 文件正确导入,以及所有内容。

关于java - Zip extractAll 未定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20563292/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com