I have a large archive (zip in my case) of ~ 100 MB in size and with ~ 15000 files in it. I need to QUICKLY extract only one file from this archive.
I tried the following 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 there another way to find the desired file in the archive? For example, on linux, this is extremely fast with the command
unzip archive.zip myfile.name
In general, I need to find and unzip one file from an archive. It may be some other format ... Maybe with a different format it may be easier.
source share