[問題] 解壓縮Jar檔案
我找了一段可以解壓縮 Zip 的程式碼來用,他可以成功解壓縮Jar但如果要解壓縮的檔案
內有資料夾他就會放棄解壓縮這個檔案,請問要如何控制要解壓縮哪些附檔名即可,或是
全部都解壓縮,我在寫一段把我不要的刪除,當然如果有辦法達到前者的要求就太棒了!
-------------------------------程式碼-----------------------------------------
void 解壓縮(String 檔案位置) {
try {
ZipInputStream Zin = new ZipInputStream(new FileInputStream(檔案位置));
System.out.println(檔案位置);
BufferedInputStream Bin = new BufferedInputStream(Zin);
String Parent = 解壓縮輸出位置;
File Fout = null;
ZipEntry entry;
try {
while ((entry = Zin.getNextEntry()) != null && !entry.isDirectory()) {
Fout = new File(Parent, entry.getName());
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();
}
Bin.close();
Zin.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 175.182.233.107
※ 文章網址: https://www.ptt.cc/bbs/java/M.1434103071.A.6AF.html
推
06/12 19:03, , 1F
06/12 19:03, 1F
→
06/12 19:04, , 2F
06/12 19:04, 2F
→
06/12 22:40, , 3F
06/12 22:40, 3F
→
06/13 03:32, , 4F
06/13 03:32, 4F
java 近期熱門文章
PTT數位生活區 即時熱門文章