首页 > 编程语言 > 详细

java 解压缩 中文名称问题

时间:2017-05-03 10:24:28      阅读:238      评论:0      收藏:0      [点我收藏+]

public List<String> unZip(String pathString, String zipPathString) {
long startTime = System.currentTimeMillis();
List<String> list = new ArrayList<>();
try {
Charset charset = Charset.forName("GBK");
ZipInputStream Zin = new ZipInputStream(new FileInputStream(
zipPathString), charset);// 输入源zip路径
BufferedInputStream Bin = new BufferedInputStream(Zin);
String Parent = pathString; // 输出路径(文件夹目录)
File Fout = null;
ZipEntry entry;
// List<ImgItem> list = new ArrayList<ImgItem>();
try {
while ((entry = Zin.getNextEntry()) != null
&& !entry.isDirectory()) {
String filenameString = entry.getName();
list.add(filenameString);
Fout = new File(Parent, filenameString);
if (!Fout.exists()) {
(new File(Fout.getParent())).mkdirs();
}
FileOutputStream out = new FileOutputStream(Fout);
BufferedOutputStream Bout = new BufferedOutputStream(out);
int b;
while ((b = Bin.read()) != -1) {
Bout.write(b);
}
Bout.close();
out.close();
System.out.println(Fout + "解压成功");
}
Bin.close();
Zin.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
long endTime = System.currentTimeMillis();
System.out.println("耗费时间: " + (endTime - startTime) + " ms");
return list;
}

java 解压缩 中文名称问题

原文:http://www.cnblogs.com/sddychj/p/6800489.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!