標籤: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 解壓縮 中文名稱問題