环境:后端java+前端Vue
1.建立一个FileZip文件类
/**
*
* @param os 输出流
* @param path 要进行操作的文件夹
* @throws IOException
*/
@Override
public static void downloadZip(OutputStream os, String path) throws IOException {
File f = new File(path);
if (!f.exists()) {
throw new FileNotFoundException(String.format("File or directory %s not found", path));
}
if (!f.isDirectory()) {
throw new FileNotFoundException(String.format("directory %s not found", path));
}
try (ZipOutputStream zip = new ZipOutputStream(os);