背景:在java自带的ZipEntry解压含有中文名名文件的压缩包乱码
解决:Apache中ant.jar支持中文,但整个包较大,在Android里不合适,只提取里文件处理这部分
部分解压代码:
zf = new ZipFile(zipFilenamePath, "GBK");
Enumeration<ZipEntry> entris = zf.getEntries();
if (entris != null) {
while (entris.hasMoreElements()) {
ze = entris.nextElement();
// 不进行文件夹的处理,些为特殊处理
if (ze.isDirectory()) {
} else {
is = zf.getInputStream(ze);
String fileName = ze.getName();
int index = fileName.lastIndexOf("/");
fileName = fileName.substring(index + 1);
bos = new BufferedOutputStream(new FileOutputStream(fileName));
while ((readLen = is.read(buf)) > 0) {
bos.write(buf, 0, readLen);
}
bos.flush();
}
}
}