How to load a properties file in java without calling laod method separately
i want to load the file while instantiation of the properties object itself.
like i have pasted below but i am not able to succeed in it.
class test{
Properties configFile = new Properties(load(new FileInputStream("config.properties"));
}
Just create a separate method to do that – potentially in a helper class you can use elsewhere:
Note that due to the possibility of an
IOException, you’ll still need to be careful where you call this from. If you want to use it in an instance initializer, you’ll need to declare that all of your constructors can throwIOException.