我想压缩目录并使用apache commons压缩库解压缩,所以
我怎么能这样做?
感谢所有
答案 0 :(得分:0)
如果你想压缩目录,可以选择
public static void createZip(String directoryPath, String zipPath) throws IOException {
FileOutputStream fOut = null;
BufferedOutputStream bOut = null;
ZipArchiveOutputStream tOut = null;
try {
fOut = new FileOutputStream(new File(zipPath));
bOut = new BufferedOutputStream(fOut);
tOut = new ZipArchiveOutputStream(bOut);
addFileToZip(tOut, directoryPath, "");
} finally {
tOut.finish();
tOut.close();
bOut.close();
fOut.close();
}
}