一、打包成zip:ZipUtil
/**
* 打包resources目录下的文件夹(不能递归压缩)
* @param filePath
* @param zipName
* @param pattern 通配符,如/**
*/
@SneakyThrows(IOException.class)
public static void zipResources(String filePath, String zipName, String pattern) {
ZipOutputStream zipOutputStream = null;
try {
long start = System.currentTimeMillis();
zipOutputStream = new ZipOutputStream(new FileOutputStream(zipName));
zipResources(zipOutputStream, zipName, filePath, pattern);
log.info("文件压缩完毕,耗时:{}", System.currentTimeMillis() - start);
} finally {
if (zipOutputStream != null) {
zipOutputStream.close();
}
}
}
/**
* 压缩文件
* @param out
* @param zipName
* @param sourceParentPath
* @param pattern 通配