comparison artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/Config.java @ 558:609ced80bcf0

Fixed: used java 7 feature although java 6 comliance level is configured
author gernotbelger
date Thu, 28 Jun 2018 19:16:06 +0200
parents ba31ca213c88
children 2b631f788ce1
comparison
equal deleted inserted replaced
557:5e487570d855 558:609ced80bcf0
6 * or visit http://www.gnu.org/licenses/ if it does not exist. 6 * or visit http://www.gnu.org/licenses/ if it does not exist.
7 */ 7 */
8 8
9 package org.dive4elements.artifacts.common.utils; 9 package org.dive4elements.artifacts.common.utils;
10 10
11 import java.io.BufferedInputStream;
11 import java.io.File; 12 import java.io.File;
13 import java.io.FileInputStream;
12 import java.io.IOException; 14 import java.io.IOException;
13 import java.io.InputStreamReader; 15 import java.io.InputStream;
14 import java.nio.charset.StandardCharsets;
15 import java.nio.file.Files;
16 import java.util.Properties; 16 import java.util.Properties;
17 17
18 import javax.xml.namespace.QName; 18 import javax.xml.namespace.QName;
19 import javax.xml.parsers.DocumentBuilderFactory; 19 import javax.xml.parsers.DocumentBuilderFactory;
20 import javax.xml.parsers.ParserConfigurationException; 20 import javax.xml.parsers.ParserConfigurationException;
74 config = loadConfig(); 74 config = loadConfig();
75 } 75 }
76 return config; 76 return config;
77 } 77 }
78 78
79 public static Properties loadProperties(final String CONFIG_FILE_LOCAL) { 79 public static Properties loadProperties(final String CONFIG_FILE_LOCAL) throws IOException {
80 final File configDir = getConfigDirectory(); 80 final File configDir = getConfigDirectory();
81 final File configFile = new File(configDir, CONFIG_FILE_LOCAL); 81 final File configFile = new File(configDir, CONFIG_FILE_LOCAL);
82 82
83 final Properties properties = new Properties(); 83 InputStream reader = null;
84 InputStreamReader reader;
85 try { 84 try {
86 reader = new InputStreamReader(Files.newInputStream(configFile.toPath()), StandardCharsets.ISO_8859_1); 85 reader = new BufferedInputStream(new FileInputStream(configFile));
86
87 final Properties properties = new Properties();
87 properties.load(reader); 88 properties.load(reader);
88 } 89 return properties;
89 catch (final IOException e) { 90 } finally {
90 e.printStackTrace(); 91 try {
91 } 92 if (reader != null)
92 93 reader.close();
93 return properties; 94 }
95 catch (final IOException e1) {
96 e1.printStackTrace();
97 }
98 }
94 } 99 }
95 100
96 /** 101 /**
97 * Returns the path to the configuartion directory. If a path 102 * Returns the path to the configuartion directory. If a path
98 * was specified via the CONFIG_DIR system property this one 103 * was specified via the CONFIG_DIR system property this one

http://dive4elements.wald.intevation.org