導航:首頁 > 文件目錄 > 怎麼壓縮文件為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包相關的資料

熱點內容
IccID未知是有網路鎖嗎 瀏覽:101
蘋果5s怎麼定位蘋果6手機 瀏覽:556
蘋果手機港版怎麼解鎖 瀏覽:189
根據xml規則讀取excel文件 瀏覽:28
網路刪除文件 瀏覽:325
蘋果怎麼共享wifi網路列印機 瀏覽:368
怎麼用鍵盤拷貝u盤文件 瀏覽:664
js炫酷特效 瀏覽:69
什麼樣的app最有市場 瀏覽:563
騰訊地圖如何截圖工具 瀏覽:69
數據處理主要方法有哪些 瀏覽:567
ps6拖文件無法打開 瀏覽:668
有哪些比較好的書評app 瀏覽:520
java中char表示範圍 瀏覽:154
python編程操作題如何批改 瀏覽:1
網路是什麼原理圖 瀏覽:670
apk音樂提取工具 瀏覽:89
怎樣共享wifi密碼設置 瀏覽:281
javamesdk8 瀏覽:503
屬於聲音格式的文件有哪些 瀏覽:373

友情鏈接