| | |
| | | import org.apache.commons.logging.LogFactory; |
| | | |
| | | import java.io.File; |
| | | import java.nio.charset.Charset; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | |
| | | 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(); |
| | |
| | | /** |
| | | * 获取ZipParameters |
| | | */ |
| | | public static ZipParameters getZipParams(boolean flag) { |
| | | public static ZipParameters getZipParams(boolean hasPwd) { |
| | | // 设置压缩文件参数 |
| | | ZipParameters params = new ZipParameters(); |
| | | // 压缩方式 |
| | |
| | | // 压缩级别 |
| | | params.setCompressionLevel(CompressionLevel.MAXIMUM); |
| | | |
| | | if (flag) { |
| | | if (hasPwd) { |
| | | // 是否设置加密文件 |
| | | params.setEncryptFiles(true); |
| | | // 设置AES加密强度:KEY_STRENGTH_256 |