[PATCH] Fixed: used java 7 feature although java 6 comliance level is configured

Wald Commits scm-commit at wald.intevation.org
Thu Jun 28 19:16:13 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1530206166 -7200
# Node ID 609ced80bcf01b938e5c999ccfb3ec017373102e
# Parent  5e487570d855651d1a92489a2d93df1736e463a2
Fixed: used java 7 feature although java 6 comliance level is configured

diff -r 5e487570d855 -r 609ced80bcf0 artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/Config.java
--- a/artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/Config.java	Wed Jun 27 14:41:15 2018 +0200
+++ b/artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/Config.java	Thu Jun 28 19:16:06 2018 +0200
@@ -8,11 +8,11 @@
 
 package org.dive4elements.artifacts.common.utils;
 
+import java.io.BufferedInputStream;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
+import java.io.InputStream;
 import java.util.Properties;
 
 import javax.xml.namespace.QName;
@@ -76,21 +76,26 @@
         return config;
     }
 
-    public static Properties loadProperties(final String CONFIG_FILE_LOCAL) {
+    public static Properties loadProperties(final String CONFIG_FILE_LOCAL) throws IOException {
         final File configDir = getConfigDirectory();
         final File configFile = new File(configDir, CONFIG_FILE_LOCAL);
 
-        final Properties properties = new Properties();
-        InputStreamReader reader;
+        InputStream reader = null;
         try {
-            reader = new InputStreamReader(Files.newInputStream(configFile.toPath()), StandardCharsets.ISO_8859_1);
+            reader = new BufferedInputStream(new FileInputStream(configFile));
+
+            final Properties properties = new Properties();
             properties.load(reader);
+            return properties;
+        } finally {
+            try {
+                if (reader != null)
+                    reader.close();
+            }
+            catch (final IOException e1) {
+                e1.printStackTrace();
+            }
         }
-        catch (final IOException e) {
-            e.printStackTrace();
-        }
-
-        return properties;
     }
 
     /**


More information about the Dive4Elements-commits mailing list