【发布时间】:2011-11-18 18:38:28
【问题描述】:
我设法使用这段简单的代码在 java 中创建了 zip 文件:
BufferedInputStream origin = null;
FileOutputStream dest = new FileOutputStream(zipFile);
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
out.setMethod(ZipOutputStream.DEFLATED);
out.setLevel(5);
byte data[] = new byte[BUFFER];
FileInputStream fi = new FileInputStream(file);
origin = new BufferedInputStream(fi, BUFFER);
ZipEntry entry = new ZipEntry(file.getName());
out.putNextEntry(entry);
int count;
while ((count = origin.read(data, 0, BUFFER)) != -1) {
out.write(data, 0, count);
}
out.closeEntry();
origin.close();
out.close();
zip 文件创建成功。但是,当我尝试使用 WinZip 或其他一些工具解压缩它时,我得到一个错误:
Central and local directory mismatch for file "my_file" (general
purpose flags - local:808 hex central: 8 hex).
Severe Error: Local and central GPFlags values don't match.
真正奇怪的是,当我解压文件时,WinRAR 和内部 Win7 zip 不会显示任何错误。
我做错了什么?有人有这个问题吗? 非常感谢!
【问题讨论】:
-
找到相关问题,我也在Android 2.3中使用java:stackoverflow.com/questions/7407695/…