From cc8c493594581bfca901550c8e1f5df932781014 Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Mon, 31 Aug 2020 16:07:03 +0300 Subject: [PATCH] Use default charset for tech type CSV parsing gitlab #93 Change-Id: Iba22b4ea4db7a772664e2b76ab44a88a70ea8e80 --- .../org/simantics/district/imports/DistrictImportUtils.java | 3 ++- .../district/network/ui/techtype/table/TechTypeTable.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java b/org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java index 0b6edb5f..d9dac92c 100644 --- a/org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java +++ b/org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java @@ -2,6 +2,7 @@ package org.simantics.district.imports; import java.io.IOException; import java.io.Reader; +import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -65,7 +66,7 @@ public class DistrictImportUtils { public static Map readCSVHeader(Path source, CSVFormat format, boolean firstAsHeader) throws IOException { if (firstAsHeader) format = format.withFirstRecordAsHeader(); - try (CSVParser parser = format.parse(Files.newBufferedReader(source))) { + try (CSVParser parser = format.parse(Files.newBufferedReader(source, Charset.defaultCharset()))) { return parser.getHeaderMap(); } } diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java index eb83c902..3b3d4a70 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java @@ -196,7 +196,7 @@ public class TechTypeTable extends Composite { public void setTechTypePath(String path) { String data; try { - data = Files.lines(Paths.get(path)).collect(Collectors.joining("\n")); + data = Files.lines(Paths.get(path), Charset.defaultCharset()).collect(Collectors.joining("\n")); } catch (IOException e) { LOGGER.error("Failed to read contents of file '{}' as {}", path, Charset.defaultCharset(), e); return; -- 2.47.1