pom.xml添加依赖
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.15</version>
</dependency>
代码
String path="";//需要压缩的文件路径
String zipPath="";//文件压缩存放的位置
ZipUtil.zip(path, zipPath);