Github user tellison commented on a diff in the pull request:
https://github.com/apache/incubator-pirk/pull/27#discussion_r72588448
--- Diff: src/main/java/org/apache/pirk/utils/SystemConfiguration.java ---
@@ -160,4 +138,74 @@ public static void resetProperties()
clearProperties();
initialize();
}
+
+ /**
+ * Loads the properties from local properties file in the specified
directory
+ * <p>
+ * Only files ending in '.properties' will be loaded
+ */
+ public static void loadPropsFromDir(String dirName)
+ {
+ File dir = new File(dirName);
+ File[] directoryListing = dir.listFiles();
+ if (directoryListing != null)
+ {
+ for (File file : directoryListing)
+ {
+ if (file.getName().endsWith(".properties"))
+ {
+ loadPropsFromFile(file);
+ }
+ }
+ }
+ }
+
+ /**
+ * Loads the properties from the specified file
+ */
+ public static void loadPropsFromFile(File file)
+ {
+ if (file.exists())
+ {
+ try (InputStream stream = new FileInputStream(file);)
+ {
+ logger.info("Loading properties file '" + file.getAbsolutePath() +
"'");
+ props.load(stream);
+ stream.close();
--- End diff --
No need to explicitly close() the stream now, the try-with-resources does
that for you.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---