java - Multiple properties files -
in java application, using .properties file access application related config properties.
eg.
appconfig.properties
contents of say,
settings.user1.name=userone settings.user2.name=usertwo settings.user1.password=passwrd1! settings.user2.password=passwrd2!
i accesing these properties through java file - appconfiguration.java
private final properties properties = new properties(); public appconfiguration(){ properties.load(thread.currentthread().getcontextclassloader() .getresourceasstream("appconfig.properties")); }
now, instead of keeping key-value properties in 1 file, divide them in few files(appconfig1.properties, appconfig2.properties, appconfig3.properties etc.).
know if possible load these multiple files simultaneously.
my question not similar - multiple .properties files in java project
thank you.
yes. have multiple load statements.
properties.load(thread.currentthread().getcontextclassloader() .getresourceasstream("appconfig1.properties")); properties.load(thread.currentthread().getcontextclassloader() .getresourceasstream("appconfig2.properties")); properties.load(thread.currentthread().getcontextclassloader() .getresourceasstream("appconfig2.properties"));
all key-value pairs available use using properties object.
Comments
Post a Comment