導航:首頁 > 文件目錄 > 怎麼壓縮文件為jar包

怎麼壓縮文件為jar包

發布時間:2023-01-19 15:40:55

文件夾壓縮成JAR

如果文件夾在目錄為c:/src
則cmd,然後進入c:/src目錄,
然後 jar cvf jar名稱.jar *
這樣既可。其中*表示將src目錄下所有的文件都放在jar文件當中

② 怎麼將一個文件夾壓縮成jar包

先解壓,然後壓縮為zip,然後將後綴名改為jar。
java工具是可實現批量壓縮文件包為jar包,核心代碼如下:

/**
* zip壓縮
* @param parentDirPath 要壓縮文件夾的父文件夾
* @param targetPath 目標文件夾
*/
private static void zipDirectory(String parentDirPath,String targetPath)
{
try {
File dirFile=new File(parentDirPath);
File[] listArr = dirFile.listFiles();
for (File childFile : listArr) {
//File childFile=new File(child);
if(childFile.isDirectory())
{
if(list.size()>0)
list.clear();
byte b[] = new byte[128];
//壓縮文件的保存路徑
String zipFile =targetPath+File.separator+childFile.getName()+".jar";

//壓縮文件目錄
String filepath =childFile.getAbsolutePath()+File.separator;

List fileList = allFile(filepath);

FileOutputStream fileOutputStream = new FileOutputStream(zipFile);
//使用輸出流檢查
CheckedOutputStream cs = new CheckedOutputStream(fileOutputStream, new CRC32());
//聲明輸出zip流
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
cs));

for (int i = 0; i < fileList.size(); i++) {
InputStream in = new FileInputStream((String)fileList.get(i));
String fileName = ((String)(fileList.get(i))).replace(File.separatorChar,'/');
System.out.println("ziping " + fileName);
String tmp= childFile.getName()+"/";
fileName = fileName.substring(fileName.lastIndexOf(tmp)+childFile.getName().length()+1);
ZipEntry e = new ZipEntry(fileName);
out.putNextEntry(e);
int len = 0;
while((len = in.read(b)) != -1) {
out.write(b,0,len);
}
out.closeEntry();
}
out.close();
System.out.println("done!");
}
}

} catch (Exception e) {
e.printStackTrace();
}

}

③ 怎麼把文件壓縮成jar格式的壓縮文件

JAR格式的程序是JAVA應用,是需要編程的,RAR是壓縮文件,直接壓縮文件夾就有的,如果你的RAR文件裡面有JAR文件,直接解壓就行了。右鍵,解壓

④ 如何將文件夾打包成JAR包

這個我知道,首復先把.rar的壓縮包制解壓,打開解壓出的文件夾,必須保證裡面有classic之類的文件(確保是手機java程序),然後把這個文件夾下的全部內容打包(注意,只有這個文件夾下的全部內容,不要包含這個文件夾本身)成zip壓縮包(一定是zip),然後把這個壓縮包的擴展名改成jar,就可以了(zip和jar是同一種格式,只要重命名就可以了),這樣你的手機就可以讀取了

閱讀全文

與怎麼壓縮文件為jar包相關的資料

熱點內容
ps3文件分割視頻 瀏覽:280
微信圖片一鍵轉發軟體 瀏覽:331
如何判斷s200plc編程電纜 瀏覽:691
太原編程培訓班哪個好 瀏覽:171
樹葉吹奏教程 瀏覽:6
社交app帶來了哪些社會問題 瀏覽:394
如何安裝愛寶8800數據採集器 瀏覽:712
文件保存了怎麼找不到了 瀏覽:476
彩票網站怎麼辨真假 瀏覽:840
pr找不到該文件 瀏覽:963
java移除panel 瀏覽:354
jsp填充jsp 瀏覽:166
海關外貿大數據在哪裡查 瀏覽:381
思特奇java筆試題 瀏覽:121
葫蘆俠在手機中的文件名 瀏覽:813
plc編程應該怎麼收錢 瀏覽:584
c語言中源文件由什麼組成 瀏覽:890
linuxhttpdphp配置文件 瀏覽:607
拆單數據要怎麼保存 瀏覽:17
mac電腦怎樣壓縮文件到100m 瀏覽:645

友情鏈接