Java解壓檔案

2021-09-24 10:00:19 字數 1005 閱讀 1827

public class urltest  catch (exception e) 

}

//從總目錄下解壓檔案裡所有的壓縮包至目的檔案路徑

public static void unzipfromloc(string filepath) throws exception

} }

/**

* 解壓檔案到指定目錄

* 解壓後的檔名,和之前一致

* @param zipfile 待解壓的zip檔案

* @param descdir 指定目錄

*/

public static void unzipfiles(file zipfile, string descdir) throws ioexception

for (enumeration<? extends zipentry> entries = zip.entries(); entries.hasmoreelements();)

// 判斷檔案全路徑是否為資料夾,如果是上面已經上傳,不需要解壓

if (new file(outpath).isdirectory())

// 輸出檔案路徑資訊

// system.out.println(outpath);

fileoutputstream out = new fileoutputstream(outpath);

byte buf1 = new byte[1024];

int len;

while ((len = in.read(buf1)) > 0)

in.close();

out.close();

} system.out.println("******************解壓完畢********************");

return;

}

java解壓zip檔案

解壓檔案 param zipfile 目標檔案 param descdir 指定解壓目錄 return public static boolean unzip file zipfile,string descdir zipfile zip null try 判斷檔案全路徑是否為資料夾,如果是上面已經...

使用java實現zip檔案的解壓

最近,使用到了對zip檔案進行解壓,順便整理了一下對檔案流的處理,一起梳理一下,方便日後使用 首先來說對檔案進行讀取和複製是常見操作,先看一下乙個簡單實現 public static void copy bos.close bis.close catch filenotfoundexception ...

java 關於壓縮包檔案的解壓

解壓zip檔案 param sourcefile 解壓檔案存放路徑 待解壓的zip檔案 tofolder,解壓後的存放路徑 throws exception public static void ziptofile string sourcefile,string tofolder throws e...