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

熱點內容
哪個app能看哈雷與戴維森 瀏覽:758
Linux的文件上傳到hdfs 瀏覽:544
系統升級win10需要再重裝么 瀏覽:205
u盤文件防止刪除 瀏覽:671
jsp字體粗體 瀏覽:775
sw安裝程序顯示找不到文件 瀏覽:714
手機傳文件到電腦的視頻在哪裡 瀏覽:245
商會網站搭建多少費用 瀏覽:159
zbrush4r7視頻教程 瀏覽:473
java前景2016 瀏覽:692
c代碼設置窗體屬性 瀏覽:179
excelvba自動保存文件 瀏覽:926
計算機java語言答案 瀏覽:184
如何找出手機應用的數據 瀏覽:62
企業門戶網站php 瀏覽:945
vray書房照片級教程 瀏覽:530
微信幽默頭像圖片大全 瀏覽:474
excel打開顯示文件被移動 瀏覽:994
中國人買蘋果手機比例 瀏覽:17
學會計要會什麼編程語言 瀏覽:130

友情鏈接