user745323
user745323

Reputation: 163

Android - unzipping zip files that are password encoded

is it possible to unzip files that have been zipped using a password?

I have search and cannot find any examples or mentions in the docs.

A link to docs or code samples would be great.

Thank you,

Mike

Upvotes: 7

Views: 18339

Answers (2)

mudit
mudit

Reputation: 25534

Refer to this question:

How to unzip a password protected file in Android

It uses a zip4j lib which works perfectly fine on android:

try {
    File src = new File("/sdcard/abc.zip");
    ZipFile zipFile = new ZipFile(src);
    if (zipFile.isEncrypted()) {
        zipFile.setPassword("a");
    }
    String dest = new String("/sdcard/abc");
    zipFile.extractAll(dest);
    } catch (ZipException e) {
       e.printStackTrace();
    }

Upvotes: 7

Rejinderi
Rejinderi

Reputation: 11844

You are right, the java.util.zip package does not support password zipping and unzipping functionality. You have to find other ways to implement it yourself. I did help search a bit see if you find this link useful :) http://blog.alutam.com/2009/10/31/reading-password-protected-zip-files-in-java/

Upvotes: 5

Related Questions