码迷,mamicode.com
首页 > 编程语言 > 详细

java 解压缩 中文名称问题

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

标签:for   write   ppa   sdi   exists   rtti   git   har   zip   

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 解压缩 中文名称问题

标签:for   write   ppa   sdi   exists   rtti   git   har   zip   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!