0

I am trying to decompressing .zip, programmatically in my application with the help of this code,

public void unzip(String _zipFile, String _targetLocation) {

    dirChecker(_targetLocation);

    try {
        FileInputStream fin = new FileInputStream(_zipFile);
        ZipInputStream zin = new ZipInputStream(fin);
        ZipEntry ze = null;

        while ((ze = zin.getNextEntry()) != null) {
            if (ze.isDirectory()) {
                dirChecker(ze.getName());
            } else {
                FileOutputStream fout = new FileOutputStream(_targetLocation + ze.getName());
                for (int c = zin.read(); c != -1; c = zin.read()) {
                    fout.write(c);
                }

                zin.closeEntry();
                fout.close();
            }
        }
        zin.close();

        Log.i("xoxo", "unzip: completed!!!");
    } catch (Exception e) {
        Log.i("xoxo", "unzip: err: - " + e.toString());
    }
}

Everything is fine, but the problem is I am getting an error,

java.util.zip.ZipException: only DEFLATED entries can have EXT descriptor

While trying to decompress .zip created by server that is running on linux environment.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Aditya
  • 3,525
  • 1
  • 31
  • 38

1 Answers1

0

You can try this library https://github.com/ankitdubey021/ExtractionLib

void extract(){

try {
    File outputFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), "value1.jar");
    Extract.extract(outputFile, new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), "extration").toString());

    Toast.makeText(MainActivity.this, "Extracted!", Toast.LENGTH_SHORT).show();
}catch(Exception e){
    System.out.println(e);
}}

It will easily extract your zip file. 3 years back I used it in a project. and still working.

Ankit Dubey
  • 1,000
  • 1
  • 8
  • 12