管道基础大数据平台系统开发-【后端】-Server
13693261870
2024-03-25 b6b0cb226fcf184525ee7b36af3a09471e9c0057
src/main/java/com/lf/server/helper/Zip4jHelper.java
@@ -11,6 +11,7 @@
import org.apache.commons.logging.LogFactory;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/**
@@ -64,6 +65,7 @@
    public static ZipFile createZipFile(String zipFile, String pwd) {
        try {
            ZipFile zip = StringHelper.isEmpty(pwd) ? new ZipFile(zipFile) : new ZipFile(zipFile, pwd.toCharArray());
            // zip.setCharset(Charset.forName("GBK"))
            zip.setCharset(StandardCharsets.UTF_8);
            File f = zip.getFile();
@@ -84,7 +86,7 @@
    /**
     * 获取ZipParameters
     */
    public static ZipParameters getZipParams(boolean flag) {
    public static ZipParameters getZipParams(boolean hasPwd) {
        // 设置压缩文件参数
        ZipParameters params = new ZipParameters();
        // 压缩方式
@@ -92,7 +94,7 @@
        // 压缩级别
        params.setCompressionLevel(CompressionLevel.MAXIMUM);
        if (flag) {
        if (hasPwd) {
            // 是否设置加密文件
            params.setEncryptFiles(true);
            // 设置AES加密强度:KEY_STRENGTH_256