I am new to Java.
I have a requirement to load a configuration file (only one time, at app start up). What is the best way to do this? I have the following ideas:
Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
getClass().getClassLoader().getResourceAsStream(resourceName);
Out of these two which is the best and why?
Say for example, I have a method like below
public void loadConfig(String name) {
InputStream streamByContextClassLoader = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
}
If I call this method multiple times, is the config file loaded multiple times? Can any Please clarify my doubt?