【发布时间】:2011-08-22 14:17:36
【问题描述】:
我只想提取一个普通的 zip 文件,但总是失败。 这是我现在使用的代码:
private File downloadPath = new File(Environment.getExternalStorageDirectory() + "/Test/file.zip");
private File unzipLoc = new File(Environment.getExternalStorageDirectory() + "/Test/");
FileInputStream fin = new FileInputStream(downloadPath);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null)
{
FileOutputStream fout = new FileOutputStream(unzipLoc + ze.getName());
for (int c = zin.read(); c != -1; c = zin.read())
{
fout.write(c);
}
zin.closeEntry();
fout.close();
}
zin.close();
在“zin.getNextEntry()”部分失败。 错误:java.util.zip.ZipException:无法读取版本 有任何想法吗?谢谢!
【问题讨论】:
-
您的 ZIP 文件好像无效。
标签: android .net file zip unzip