I need to ask for the best way how to read the configuration file for my application. Currently what I'm doing is put the above code in my Java program, get all configuration item that I want, and then pass the value to the function that requires the variable.
What is the best way for me to let the configuration file to load only once and can be used in the other process (other users)?
File configFile = new File("D:\\config.properties");
try {
FileReader reader = new FileReader(configFile);
Properties prop = new Properties();
prop.load(reader);
String dbName = prop.getProperty("dbName");
String dBase = prop.getProperty("database");
String strMethod1 = prop.getProperty("method1");
int method1 = Integer.parseInt(strMethod1);
String strMethod2 = prop.getProperty("method2");
int method2 = Integer.parseInt(strMethod2);
} catch (IOException e) {
returnValue = IO_EXCEPTION;
logger.error("IOException:::" + e + " returnValue:::" + returnValue);
}