/**
* zip("D://zipfilename.zip", new File("D://项目文档//sql"), "");
*/
public static void zip(String zipFileName, File inputFile, String zipname)
throws Exception {
ZipOutputStream out = null;
try {
out = new ZipOutputStream(new FileOutputStream(zipFileName));
zip(out, inputFile, "", zipname);
out.close();
out = null;
} finally {
try {
if (out != null) {
out.close();
out = null;
}
} catch (IOException e) {
}
}
}
压缩文件1
本文介绍了一种使用Java实现的文件压缩方法,通过ZipOutputStream将指定目录下的文件压缩到一个ZIP文件中。该方法接受三个参数:压缩后的文件名、待压缩的文件路径及压缩文件内的名称。

被折叠的 条评论
为什么被折叠?



