Zip extractAll undefined?

时间:2013-12-13 09:42:19

标签: java zip

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

代码:

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();
               }
编辑:我找到了解决方案。这是相当尴尬的,但我导入了错误的一个-.-

2 个答案:

答案 0 :(得分:1)

确保你拥有合适的罐子 http://www.lingala.net/zip4j/download.php

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

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

因此请检查您是否从正确的jar文件中正确导入了所有内容。

答案 1 :(得分:0)

我刚看了Zip4j(版本1.3.1)的源代码。方法extractAll肯定存在。确保zip4j-jar位于类路径中,并且您使用的是最新版本。

相关问题