java 壓縮檔案

2021-07-14 15:47:48 字數 833 閱讀 4417

public static final string filetype = ".zip";// 壓縮檔案型別

public static string compressedfile(string resourcepath, string targetpath, string filename)

// 目的檔案壓縮名

uuid uuid = uuid.randomuuid();

string targetname = uuid.tostring() + filetype;

fileoutputstream outstream = null;

zipoutputstream out = null;

try catch (filenotfoundexception e) finally catch (ioexception e) }}

return targetname;

}/**

* 生成壓縮檔案。 如果是資料夾,則使用遞迴,進行檔案遍歷、壓縮 如果是檔案,直接壓縮

* * @param out

* @param file

* @param dir

* @throws ioexception

*/public static void createcompressedfile(zipoutputstream out, file file, string dir)

// 當前的是檔案,打包處理

} else

}} catch (ioexception e) finally catch (ioexception e) }}

}

java壓縮檔案

壓縮 zip4j param srcdir 要壓縮資料夾 param targetdir zip檔案存放位置 param zipname 壓縮檔案名字 param encrypt 是否加密 param password 密碼 return public static boolean tozip st...

java 壓縮資料夾 zip

purpose 壓縮資料夾 author hermanwang param srcdir 需要壓縮的檔案的路徑 param out zip輸出流 param keepdirstructure 是否保留原來的目錄結構,true 保留目錄結構 false 所有檔案跑到壓縮包根目錄下 注意 不保留目錄結構...

怎樣壓縮檔案 如何給壓縮檔案加密

我們生活 工作中,會經常遇到壓縮檔案 給檔案加密的事情。有時候,是單純不想讓別人看到 有時候,是提供 但不能共享,用來獲取收益等等。那麼怎麼將乙個檔案壓縮,或者乙個資料夾壓縮尼?同時又怎麼給這個壓縮檔案加密尼?下面大家和小編一起看一下吧。壓縮檔案 如圖。找到需要壓縮的檔案 資料夾,右擊檔案,點選新增...