perf: 优化代码

This commit is contained in:
2022-11-07 00:32:16 +08:00
parent 6904a9121c
commit 244f15d021
7 changed files with 144 additions and 35 deletions

View File

@@ -18,9 +18,9 @@ public final class CommonUtils {
}
public static void zipCompressionFolder(@NotNull File folder, @NotNull File zipFile) throws IOException {
ZipOutputStream stream = new ZipOutputStream(Files.newOutputStream(zipFile.toPath()));
putFileToZipStream(stream, "", folder);
stream.close();
try (ZipOutputStream stream = new ZipOutputStream(Files.newOutputStream(zipFile.toPath()))) {
putFileToZipStream(stream, "", folder);
}
}
public static void putFileToZipStream(@NotNull ZipOutputStream stream, @NotNull String path, @NotNull File file) throws IOException {