1

I'm trying to unzip this file using Java.I found this guide: What is a good Java library to zip/unzip files? But I'm getting an error: The method extractAll(String) is undefined for the type ZipFile

Code:

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();
               }

EDIT: I found the solution. It's rather embarrassing, but I imported the wrong one -.-

Community
  • 1
  • 1
Paludan
  • 622
  • 1
  • 5
  • 21

2 Answers2

1

See to it that you have the right jar http://www.lingala.net/zip4j/download.php

I just extracted the jar there is a method in ZipFile.class

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

So please check that you have proper import from proper jar file, that all there is to it.

user1933888
  • 2,897
  • 3
  • 27
  • 36
0

I just had a look at source code of Zip4j (version 1.3.1). The method extractAll definitely exists. Make sure that the zip4j-jar is on your classpath and that you are using the latest version.

Joachim Rohde
  • 5,915
  • 2
  • 29
  • 46