From 45fbe26b5f824eae4a1b630d619365b92e523606 Mon Sep 17 00:00:00 2001 From: Marcel Pfotenhauer Date: Fri, 28 Aug 2020 13:53:48 +0200 Subject: [PATCH] #131: simplified implementation --- .../neodymium/tests/NeodymiumTest.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/xceptance/neodymium/tests/NeodymiumTest.java b/src/test/java/com/xceptance/neodymium/tests/NeodymiumTest.java index 48e199ff8..aca970ba7 100644 --- a/src/test/java/com/xceptance/neodymium/tests/NeodymiumTest.java +++ b/src/test/java/com/xceptance/neodymium/tests/NeodymiumTest.java @@ -1,7 +1,8 @@ package com.xceptance.neodymium.tests; import java.io.File; -import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.text.MessageFormat; import java.util.ArrayList; @@ -11,6 +12,7 @@ import java.util.Map; import java.util.stream.Collectors; +import org.apache.commons.io.FileUtils; import org.junit.AfterClass; import org.junit.Assert; import org.junit.runner.Description; @@ -105,17 +107,14 @@ public void checkDescription(Class clazz, String[] expectedTestDescription) t */ public static void writeMapToPropertiesFile(Map map, File file) { + String propertiesString = map.entrySet().stream() + .map(entry -> entry.getKey() + "=" + entry.getValue()) + .collect(Collectors.joining(System.lineSeparator())); try { - String propertiesString = map.keySet().stream() - .map(key -> key + "=" + map.get(key)) - .collect(Collectors.joining("\r\n")); - - FileOutputStream outputStream = new FileOutputStream(file); - outputStream.write(propertiesString.getBytes()); - outputStream.close(); + FileUtils.writeStringToFile(file, propertiesString, StandardCharsets.UTF_8); } - catch (Exception e) + catch (IOException e) { throw new RuntimeException(e); }