【发布时间】:2014-12-08 05:49:51
【问题描述】:
我无法解压缩大文件 (50 mb)。
ZipInputStream 和 ZipFile 我都试过了。
当我使用ZipFile 时出现以下异常:
java.util.zip.ZipException: EOCD 未找到;不是 Zip 存档?
当我使用ZipInputStream 时,我收到了跟随错误:
没有 zip 条目(zin.getNextEntry())
ZipInputStream代码:
public static void unzip(File _zipFile, File directory) throws IOException {
try {
FileInputStream fin = new FileInputStream(_zipFile);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
// not getting here
}
zin.close();
}
catch (Exception e) {
}
}
ZipFile代码:
public static void unzipa(File zipfile, File directory) throws IOException {
try {
ZipFile zfile = new ZipFile(zipfile); // getting exception here
Enumeration<? extends ZipEntry> entries = zfile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
}
zfile.close();
}
catch (Exception ex) {
ErroHandling.HandleError(ex);
}
}
【问题讨论】: