我正在尝试以编程方式解压缩文件(30 Mb),这是我的脚本
public void unzip() {
dirChecker(location);
try {
FileInputStream fin = new FileInputStream(zipFile);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
Log.v("Decompress", "Unzipping " + location+ze.getName());
//create dir if required while unzipping
if (ze.isDirectory()) {
dirChecker(ze.getName());
} else {
FileOutputStream fout = new FileOutputStream(location + ze.getName());
IoUtils.copyStream(zin, fout);
zin.closeEntry();
fout.close();
}
}
zin.close();
} catch (Exception e) {
System.out.println(e);
}
}
private void dirChecker(String dir) {
File f = new File(location + dir);
if (!f.isDirectory()) {
f.mkdirs();
}
}
解压缩顺利,直到 zip 中的第 24 个文件,应用程序挂起而没有给出任何错误,只需冻结在行中:
IoUtils.copyStream(zin, fout);
没有日志,没有异常,什么都没有......我发现在尝试后放置一个断点并手动循环直到第 24 个文件到达的正确行(这是一个 1.1mb jpg,我用 winzip 提取没有问题)
任何提示?