Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/DefaultBedHeights.java @ 9178:2f5052835b76
uinfo inundationduration langjÀhr. Mittel, Uedauern.properties, Meldung
author | gernotbelger |
---|---|
date | Tue, 26 Jun 2018 19:48:35 +0200 |
parents | 28eec75415d8 |
children | ed4b14389667 |
comparison
equal
deleted
inserted
replaced
9177:37db8c4c44b7 | 9178:2f5052835b76 |
---|---|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | 7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
8 * documentation coming with Dive4Elements River for details. | 8 * documentation coming with Dive4Elements River for details. |
9 */ | 9 */ |
10 package org.dive4elements.river.artifacts.sinfo.tkhstate; | 10 package org.dive4elements.river.artifacts.sinfo.tkhstate; |
11 | 11 |
12 import java.io.File; | |
13 import java.io.IOException; | |
14 import java.io.InputStreamReader; | |
15 import java.nio.charset.StandardCharsets; | |
16 import java.nio.file.Files; | |
17 import java.util.ArrayList; | 12 import java.util.ArrayList; |
18 import java.util.Arrays; | 13 import java.util.Arrays; |
19 import java.util.Collection; | 14 import java.util.Collection; |
20 import java.util.Collections; | 15 import java.util.Collections; |
21 import java.util.List; | 16 import java.util.List; |
82 | 77 |
83 return result; | 78 return result; |
84 } | 79 } |
85 | 80 |
86 private static Collection<String> loadBedHeightDefaultsForRiver(final River river, final Calculation problems) { | 81 private static Collection<String> loadBedHeightDefaultsForRiver(final River river, final Calculation problems) { |
87 final File configDir = Config.getConfigDirectory(); | |
88 final File configFile = new File(configDir, CONFIG_FILE); | |
89 | 82 |
90 final Properties properties = new Properties(); | 83 try { |
91 try (final InputStreamReader reader = new InputStreamReader(Files.newInputStream(configFile.toPath()), StandardCharsets.ISO_8859_1)) { | 84 final Properties properties = Config.loadProperties(CONFIG_FILE); |
92 properties.load(reader); | |
93 | |
94 final String value = properties.getProperty(river.getName()); | 85 final String value = properties.getProperty(river.getName()); |
95 final String[] split = StringUtils.split(StringUtils.trim(value), ','); | 86 final String[] split = StringUtils.split(StringUtils.trim(value), ','); |
96 if (ArrayUtils.isEmpty(split)) { | 87 if (ArrayUtils.isEmpty(split)) { |
97 problems.addProblem("sinfo.bedheightsfinder.configfile.missingriver", CONFIG_FILE, river.getName()); | 88 problems.addProblem("sinfo.bedheightsfinder.configfile.missingriver", CONFIG_FILE, river.getName()); |
98 return Collections.emptyList(); | 89 return Collections.emptyList(); |
99 } | 90 } |
100 | 91 |
101 return Arrays.asList(split); | 92 return Arrays.asList(split); |
102 } | 93 } |
103 catch (final IOException e) { | 94 catch ( |
95 | |
96 final Exception e) { | |
104 e.printStackTrace(); | 97 e.printStackTrace(); |
105 problems.addProblem("sinfo.bedheightsfinder.configfile.loaderror", CONFIG_FILE, e.getMessage()); | 98 problems.addProblem("sinfo.bedheightsfinder.configfile.loaderror", CONFIG_FILE, e.getMessage()); |
106 return Collections.emptyList(); | 99 return Collections.emptyList(); |
107 } | 100 } |
108 } | 101 } |