From 6f670c158813642568f8a9c1ed10bceec1d76cc3 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Tue, 8 Dec 2020 12:08:15 +0200 Subject: [PATCH] Using non default charset for uncompressing zip files. gitlab #656 Change-Id: I945522e99824f81e1755dae392d74c6b4b0e379e --- .../src/org/simantics/utils/FileUtils.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bundles/org.simantics.utils/src/org/simantics/utils/FileUtils.java b/bundles/org.simantics.utils/src/org/simantics/utils/FileUtils.java index 44a3dfcf5..c887126c2 100644 --- a/bundles/org.simantics.utils/src/org/simantics/utils/FileUtils.java +++ b/bundles/org.simantics.utils/src/org/simantics/utils/FileUtils.java @@ -28,6 +28,7 @@ import java.net.URI; import java.net.URL; import java.nio.channels.FileChannel; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; @@ -848,7 +849,14 @@ public class FileUtils { extractZip(fis, dst); } } - + + public static void extractZip(File zipFile, File dst, Charset charset) throws IOException { + if (LOGGER.isTraceEnabled()) + LOGGER.trace("Extracting zip "+zipFile); + try (FileInputStream fis = new FileInputStream(zipFile)) { + extractZip(fis, dst, charset); + } + } /** * Extract a zip file into a directory * @@ -857,8 +865,12 @@ public class FileUtils { * @throws IOException */ public static void extractZip(InputStream zipInput, File dst) throws IOException { + extractZip(zipInput, dst, StandardCharsets.UTF_8); + } + + public static void extractZip(InputStream zipInput, File dst, Charset charset) throws IOException { byte[] buf = new byte[8192]; - ZipInputStream zis = new ZipInputStream(zipInput); + ZipInputStream zis = new ZipInputStream(zipInput, charset); ZipEntry entry; entry = zis.getNextEntry(); -- 2.47.1