From 79790ea4976c9aac8a47a3fc91e20b56102a282b Mon Sep 17 00:00:00 2001 From: yjz <3131811435@qq.com> Date: Fri, 8 Mar 2024 16:38:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=BC=E5=87=BAzip=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/jero/common/util/ZipUtil.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/laws-base/laws-base-core/src/main/java/com/jero/common/util/ZipUtil.java b/laws-base/laws-base-core/src/main/java/com/jero/common/util/ZipUtil.java index 70b0e698..91b08d03 100644 --- a/laws-base/laws-base-core/src/main/java/com/jero/common/util/ZipUtil.java +++ b/laws-base/laws-base-core/src/main/java/com/jero/common/util/ZipUtil.java @@ -34,7 +34,11 @@ public class ZipUtil { try { zos = new ZipOutputStream(out); File sourceFile = new File(srcDir); - compress(sourceFile, zos, sourceFile.getName().substring(0,sourceFile.getName().lastIndexOf("_")), KeepDirStructure); + String name = sourceFile.getName(); + if (sourceFile.getName().contains("_")){ + name = sourceFile.getName().substring(0, sourceFile.getName().lastIndexOf("_")); + } + compress(sourceFile, zos, name, KeepDirStructure); long end = System.currentTimeMillis(); System.out.println("压缩完成,耗时:" + (end - start) + " ms");