我想提取一個普通的zip文件,但它保持失敗。 這是我的代碼,我現在使用:解壓zip文件給出「java.util.zip.ZipException:無法讀取版本」或「java.util.ZipException無法讀取本地頭版本45」
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文件無效。 – SLaks