|
@@ -60,16 +60,16 @@ public class ZipUtil {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 2. 创建当前 ZIP 的解压目录
|
|
|
+ // 2. 创建当前 ZIP 的解压目录(跟压缩包目录已经处理过,就不要追加到文件目录中了)
|
|
|
String currentZipName = FileUtil.mainName(currentZip);
|
|
|
String currentNestedPath = nestedPath.isEmpty()
|
|
|
- ? currentZipName
|
|
|
+ ? ""
|
|
|
: nestedPath + File.separator + currentZipName;
|
|
|
File currentOutputDir = new File(rootOutputDir, currentNestedPath);
|
|
|
FileUtil.mkdir(currentOutputDir);
|
|
|
|
|
|
- // 3. 解压当前 ZIP
|
|
|
- try (ZipFile zip = ZipFile.builder().setFile(currentZip).setCharset(encoding).get()) {
|
|
|
+ // 3. 解压当前 ZIP,支持最多10个分卷的解压
|
|
|
+ try (ZipFile zip = ZipFile.builder().setFile(currentZip).setCharset(encoding).setMaxNumberOfDisks(10).get()) {
|
|
|
Enumeration<ZipArchiveEntry> entries = zip.getEntries();
|
|
|
|
|
|
while (entries.hasMoreElements()) {
|
|
@@ -109,8 +109,7 @@ public class ZipUtil {
|
|
|
Files.delete(nestedZipFile.toPath());
|
|
|
} else {
|
|
|
// 记录路径
|
|
|
- String relativePath = rootOutputDir + File.separator + currentNestedPath + File.separator + name;
|
|
|
- decompressedFiles.add(relativePath);
|
|
|
+ decompressedFiles.add(entryPath.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -125,12 +124,17 @@ public class ZipUtil {
|
|
|
|
|
|
// 使用示例
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
- List<String> files = decompressZip(
|
|
|
- new File("C:\\Users\\Administrator\\Desktop\\上海熙盛明诚私募基金管理有限公司-信披报告.zip"),
|
|
|
- new File("C:\\Users\\Administrator\\Desktop"),
|
|
|
- 2,
|
|
|
- "UTF-8"
|
|
|
- );
|
|
|
+// List<String> files = decompressZip(
|
|
|
+// new File("C:\\Users\\Administrator\\Desktop\\上海熙盛明诚私募基金管理有限公司-信披报告.zip"),
|
|
|
+// new File("C:\\Users\\Administrator\\Desktop"),
|
|
|
+// 2,
|
|
|
+// "UTF-8"
|
|
|
+// );
|
|
|
+// System.out.println("解压后的文件路径:");
|
|
|
+// files.forEach(System.out::println);
|
|
|
+
|
|
|
+ String currentZip = "D:\\Documents\\新报告解析\\确认单\\20250514_份额及交易确认函_上海量魁私募基金管理有限公司_深圳市前海排排网基金销售有限责任公司_TA确认数据.zip";
|
|
|
+ List<String> files = decompressZip(currentZip, "D:\\Documents\\新报告解析\\确认单\\", 2, "utf-8");
|
|
|
System.out.println("解压后的文件路径:");
|
|
|
files.forEach(System.out::println);
|
|
|
}
|