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

熱點內容
怎麼查看工作目錄里的文件名 瀏覽:525
華為黃app怎麼下載 瀏覽:342
禁用U盤怎麼傳輸文件 瀏覽:88
wifi萬能密碼舊版 瀏覽:340
linux如何傳文件虛擬機 瀏覽:929
word支持的文件類型 瀏覽:286
sfc轉移號怎麼編程 瀏覽:860
平面設計教程的書籍 瀏覽:676
掃描後的文件還能改么 瀏覽:21
微信代碼怎麼沒用了 瀏覽:65
2013款卡羅拉原裝導航怎麼升級 瀏覽:860
微信掃描下載蘋果app 瀏覽:29
70煉金術升級 瀏覽:862
C文件檢驗 瀏覽:101
IccID未知是有網路鎖嗎 瀏覽:101
蘋果5s怎麼定位蘋果6手機 瀏覽:556
蘋果手機港版怎麼解鎖 瀏覽:189
根據xml規則讀取excel文件 瀏覽:28
網路刪除文件 瀏覽:325
蘋果怎麼共享wifi網路列印機 瀏覽:368

友情鏈接