java的解壓縮

2021-09-12 03:20:13 字數 1001 閱讀 2650

public static void main(string args) throws exception

outputstream os = new fileoutputstream(outpath+zipentry.getname());//建立解壓後的檔案

bufferedoutputstream bos = new bufferedoutputstream(os);//帶緩的寫出流

inputstream is = zipfile.getinputstream(zipentry);//讀取元素

bufferedinputstream bis = new bufferedinputstream(is);//讀取流的快取流

checkedinputstream cos = new checkedinputstream(bis, new crc32());//檢查讀取流,採用crc32演算法,保證檔案的一致性

byte b = new byte[1024];//位元組陣列,每次讀取1024個位元組

//迴圈讀取壓縮檔案的值

while(cos.read(b)!=-1)

cos.close();

bis.close();

is.close();

bos.close();

os.close();

} else

}system.out.println("解壓完成");

zipfile.close();

}

//壓縮檔案

public class test_ys

//遞迴,獲取需要壓縮的資料夾下面的所有子檔案,然後建立對應目錄與檔案,對檔案進行壓縮

public static void zipfile(zipoutputstream zos,file file) throws exception

}else

//關閉流

bis.close();

is.close();

}}

壓縮解壓縮

壓縮 壓縮後的檔名 包含物理路徑 待壓縮的資料夾 包含物理路徑 public static void packfiles string filename,string directory catch exception 解壓縮 待解壓檔名 包含物理路徑 解壓到哪個目錄中 包含物理路徑 public ...

壓縮 解壓縮

linux使用最廣泛的壓縮格式位gz,使用gzip命令進行壓縮和解壓縮 1 gzip,gunzip,壓縮 解壓縮檔案,compress or expand files gzip acdfhkllnnrtvv19 s suffix name gunzip acfhkllnnrtvv s suffix ...

Linux 壓縮 解壓縮

1.以.a為副檔名的檔案 tar xv file.a 2.以.z為副檔名的檔案 uncompress file.z 3.以.gz為副檔名的檔案 gunzip file.gz 4.以.bz2為副檔名的檔案 bunzip2 file.bz2 5.以.tar.z為副檔名的檔案 tar xvzf file....