Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 796
user745323 Avatar asked May 09 '11 14:05

user745323


2 Answers

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();
    }
like image 179
mudit Avatar answered Sep 29 '22 01:09

mudit


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/

like image 22
Rejinderi Avatar answered Sep 29 '22 02:09

Rejinderi