X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=sparkybe-onap-service%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fsparky%2Futil%2FConfigHelper.java;fp=sparkybe-onap-service%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fsparky%2Futil%2FConfigHelper.java;h=29436f0d48982bc283034bf5697bcba942803905;hb=41921e717d71352d3c623d137875d37b64460774;hp=9f43405783cec65494604c2fdac0f2e3085fe091;hpb=28fd048dcd052449ac2f8da76ccb9255f33fa387;p=aai%2Fsparky-be.git 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; }