我有一个大小约为100MB,包含大约15000个文件的大型存档(在我的情况下为zip)。 我需要快速从这个归档中提取一个文件。
我尝试了以下代码:
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;
}
}
功能可行,但速度太慢。
有没有其他方法在存档中找到所需文件?例如,在Linux上可以使用命令非常快速地执行此操作。
unzip archive.zip myfile.name
通常情况下,我需要从一些归档文件中找到并解压缩一个文件。它可以是其他格式...也许使用其他格式更容易。