一、导包
<!--压缩文件-->
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.10.5</version>
</dependency>
二 、工具类(FileUtil)
/**
* 压缩文件
*
* @param filePaths 需要压缩的文件路径集合
* @throws IOException
*/
public static void zipFile(List<String> filePaths, ZipOutputStream zos) {
//设置读取数据缓存大小
byte[] buffer = new byte[4096];
try {
//循环读取文件路径集合,获取每一个文件的路径
for (String filePath : filePaths) {
File inputFile