@@ -22,29 +22,24 @@ public class PropertiesLoader {
2222 if (System .getProperty ("load.props" ) != null )
2323 IS_ENABLED = Boolean .parseBoolean (System .getProperty ("load.props" , "true" ));
2424 if (IS_ENABLED )
25- loadProperties ("./" );
25+ loadProperties ();
2626 }
2727
2828 public static void setLogger (Logger logger ) {
2929 PropertiesLoader .logger = logger ;
3030 }
3131
32+ public static void loadProperties () {
33+ loadProperties ("./sqlbrowserfx.properties" );
34+ }
35+
3236 public static void loadProperties (String rootPath ) {
3337 try (var walk = Files .walk (Paths .get (rootPath ))) {
3438 walk
3539 .filter (Files ::isRegularFile )
3640 .filter (path -> path .toString ().endsWith (".properties" ))
3741 .forEach (path -> {
38- try (InputStream inputStream = new FileInputStream (path .toFile ())) {
39- Properties props = new Properties ();
40- props .load (inputStream );
41- propertiesMap .put (path .getFileName ().toString (), props );
42- } catch (IOException e ) {
43- if (logger != null )
44- logger .error (e .getMessage ());
45- else
46- e .printStackTrace ();
47- }
42+ loadProperties (path .toFile ());
4843 });
4944 } catch (IOException e ) {
5045 if (logger != null )
@@ -53,6 +48,19 @@ public static void loadProperties(String rootPath) {
5348 System .err .println ("Could not read property from file" );
5449 }
5550 }
51+
52+ private static void loadProperties (File file ) {
53+ try (InputStream inputStream = new FileInputStream (file )) {
54+ Properties props = new Properties ();
55+ props .load (inputStream );
56+ propertiesMap .put (file .getName (), props );
57+ } catch (IOException e ) {
58+ if (logger != null )
59+ logger .error (e .getMessage ());
60+ else
61+ e .printStackTrace ();
62+ }
63+ }
5664
5765 @ SuppressWarnings ("unchecked" )
5866 public static <T > T getProperty (String fileKey , String key , Class <?> clazz ) {
0 commit comments