嗨,我是zip格式的新手,我使用Java的util实现来解压缩文件,但是每当我尝试打开文件时它都会抛出一个ZipException . 我检查文件是否已损坏,但不是因为我可以使用winRar打开它 .
所以我继续尝试 appache.commons.vfs 包来做同样的事情,这也导致了失败 .
作为最后的尝试,我尝试了7-zip-jbinding库,并且能够读取Zip存档的内容,但我无法提取它 .
这是我的本机java实现的代码:
BufferedOutputStream dest = null;
FileInputStream fis = new FileInputStream(archive);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
ZipEntry entry;
File destFile;
destinationDir.mkdir();
while ((entry = zis.getNextEntry()) != null) {
String currentfileName = entry.getName();
destFile = new File(destinationDir, currentfileName);
File destinationParent = destFile.getParentFile();
destinationParent.mkdirs();
if (!entry.isDirectory()) {
int currentByte;
byte