From 7f476aa021fb85d822be936905ba84ee2a20a8d5 Mon Sep 17 00:00:00 2001 From: zhn <947514737@qq.com> Date: Tue, 14 Jun 2022 15:47:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E5=BA=93=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/jero/modules/split/common/FileUnZip.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/common/FileUnZip.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/common/FileUnZip.java index a65d1e365..9962c9ba9 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/common/FileUnZip.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/common/FileUnZip.java @@ -37,17 +37,22 @@ public class FileUnZip { } ZipFile zip = new ZipFile(zipFile,"gbk"); String orgMkdirs = ""; + int count = 0; for (Enumeration entries = zip.getEntries(); entries.hasMoreElements(); ) { + count ++; ZipEntry entry = (ZipEntry) entries.nextElement(); String zipEntryName = entry.getName(); String outPath = (descDir + "/" + zipEntryName).replaceAll("\\*", "/"); + if(count == 1){ + orgMkdirs = outPath.substring(0, outPath.lastIndexOf('/')); + } //判断路径是否存在,不存在则创建文件路径 File file = new File(outPath.substring(0, outPath.lastIndexOf('/'))); if (!file.exists()) { - orgMkdirs = outPath.substring(0, outPath.lastIndexOf('/')); +// orgMkdirs = outPath.substring(0, outPath.lastIndexOf('/')); file.mkdirs(); }else{ - orgMkdirs = outPath.substring(0, outPath.lastIndexOf('/')); +// orgMkdirs = outPath.substring(0, outPath.lastIndexOf('/')); } //判断文件全路径是否为文件夹,如果是上面已经上传,不需要解压 if (new File(outPath).isDirectory()) {