當解壓縮zip文件時,我的jboss顯示錯誤。如何解決org.apache.commons.compress.archivers.zip.UnsupportedZipFeatureException(epub mimetype)?
錯誤消息
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的entrys的一部分:公地壓縮-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)
你可以發佈Java代碼嗎? – NEO
我用它編輯了我的問題。 –