Wednesday, June 19, 2013

Load property file on changes



import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;


public class ReadConfig {

private static PropertiesConfiguration config =  new PropertiesConfiguration();
public static synchronized String getProperty(final String key) {

                        config.setPath("<path of property file>");
config.setReloadingStrategy(new FileChangedReloadingStrategy());
config.load();
return (String) config.getProperty(key);
}


}

No comments:

Post a Comment