public class ZipUtil extends Object
public static void toZip(String srcDir, OutputStream out, boolean KeepDirStructure) throws RuntimeException
srcDir - 压缩文件夹路径out - 压缩文件输出流KeepDirStructure - 是否保留原来的目录结构,true:保留目录结构;
false:所有文件跑到压缩包根目录下(注意:不保留目录结构可能会出现同名文件,会压缩失败)RuntimeException - 压缩失败会抛出运行时异常public static void toZip(List<File> srcFiles, OutputStream out) throws RuntimeException
srcFiles - 需要压缩的文件列表out - 压缩文件输出流RuntimeException - 压缩失败会抛出运行时异常Copyright © 2022. All rights reserved.