Paludan
Paludan

Reputation: 622

Zip extractAll undefined?

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 -.-

Upvotes: 1

Views: 1237

Answers (2)

user1933888
user1933888

Reputation: 3017

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.

Upvotes: 1

Joachim Rohde
Joachim Rohde

Reputation: 6045

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.

Upvotes: 0

Related Questions