4

I have a big archive (zip in my case) with size ~100MB and with ~15000 files in it. I need to QUICKLY extract only one file form this archive.

I tried the next code:

final String zipPath = "archive.zip";
FileInputStream fin = new FileInputStream(zipPath);

in = new ZipInputStream(fin);

for (ZipEntry entry = in.getNextEntry(); entry != null; entry = in.getNextEntry()) {
    if(entry.equals("file.name")){
    //unzip this entry
    break;
}
}

It works but too SLOW.

Is it some another possibility to find necessary file in archive? For example, on linux it extremally fast possible with command

unzip archive.zip myfile.name

In general, I need to find and decompress one file from some archive. It can be some another format... May be with another format it can be more easy.

animuson
  • 53,861
  • 28
  • 137
  • 147
lubart
  • 1,746
  • 3
  • 27
  • 35

1 Answers1

1

You can use the libzip library.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
  • Hi! Thank you for reply! But if I understood good libzip is a C library, can I use it on android? – lubart Aug 05 '12 at 10:51
  • Thank you for your tip! Really, I compiled libzip for android and now I have static library libzip.a This file I include to my project and I wrote `static { System.loadLibrary("zip"); }` in Activity. Project works! May be it is stupid question, but how I can now zip and unzip files? Where I should find a functions list? Please, explain me if it not too hard for you! Thank you! – lubart Aug 08 '12 at 00:40
  • Example here: http://stackoverflow.com/questions/10440113/simple-way-to-unzip-a-zip-file-using-zlib – Mark Adler Aug 08 '12 at 01:05