我的 jboss 显示错误,而 zip 文件正在解压缩过程中。
错误信息
14:36:20,663 ERROR [STDERR] org.apache.commons.compress.archivers.zip.UnsupportedZipFeatureException: unsupported feature data descriptor used in entry mimetype
14:36:20,663 ERROR [STDERR] at org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.read(ZipArchiveInputStream.java:245)
14:36:20,663 ERROR [STDERR] at java.io.InputStream.read(Unknown Source)
这是 test.epub 条目的一部分
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
20 Stored 20 0% 03-18-2013 14:39 2cab616f mimetype
0 Stored 0 0% 03-18-2013 10:42 00000000 META-INF/
265 Defl:N 187 29% 03-18-2013 10:42 4d7842ce META-INF/container.xml
1048 Defl:N 271 74% 03-18-2013 10:42 c04d123d META-INF/encryption.xml
0 Stored 0 0% 03-18-2013 12:05 00000000 OEBPS/
1014 Defl:N 530 48% 03-18-2013 12:05 cb8218d1 OEBPS/9.html
LIB:commons-compress-1.4.jar 1.5 版本显示相同的错误消息。
任何人都知道为什么会发生错误以及我如何解决它?
添加代码
public void unzip(InputStream is, File destDir, String charsetName)
throws IOException {
ZipArchiveInputStream zis;
ZipArchiveEntry entry;
String name;
File target;
int nWritten = 0;
BufferedOutputStream bos;
byte[] buf = new byte[1024 * 8];
zis = new ZipArchiveInputStream(is, charsetName, false);
while ((entry = zis.getNextZipEntry()) != null) {
name = entry.getName();
target = new File(destDir, name);
if (entry.isDirectory()) {
target.mkdirs();
} else {
Util.createParentDirectory(target);
target.createNewFile();
bos = new BufferedOutputStream(new FileOutputStream(target));
while ((nWritten = zis.read(buf)) >= 0) {
bos.write(buf, 0, nWritten);
}
bos.close();
debug("file : " + name);
}
}
zis.close();
}
当我使用其他 LIB(Java.util.zip) 时,也会显示下面的异常。
java.util.zip.ZipException: only DEFLATED entries can have EXT descriptor
at java.util.zip.ZipInputStream.readLOC(Unknown Source)
at java.util.zip.ZipInputStream.getNextEntry(Unknown Source)