diff options
Diffstat (limited to 'sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/ConfigHelper.java')
-rw-r--r-- | sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/ConfigHelper.java | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/ConfigHelper.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/ConfigHelper.java index 9f43405..29436f0 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/ConfigHelper.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/ConfigHelper.java @@ -77,14 +77,12 @@ public class ConfigHelper { * @throws Exception the exception */ public static Properties loadConfig(String fileName) throws Exception { - String basePath = System.getProperty("user.dir"); - InputStream fileInputStream = new FileInputStream(basePath + "//" + fileName); - - Properties props = new Properties(); - props.load(fileInputStream); - - return props; + try (InputStream fileInputStream = new FileInputStream(basePath + "//" + fileName)) { + Properties props = new Properties(); + props.load(fileInputStream); + return props; + } } /** @@ -96,14 +94,11 @@ public class ConfigHelper { public static Properties loadConfigFromExplicitPath(String fileName) { Properties props = new Properties(); - - try { - InputStream fileInputStream = new FileInputStream(fileName); + try (InputStream fileInputStream = new FileInputStream(fileName)) { props.load(fileInputStream); } catch (Exception exc) { LOG.warn(AaiUiMsgs.CONFIG_NOT_FOUND_VERBOSE, fileName, exc.getLocalizedMessage()); } - return props; } |