Skip to content

Instantly share code, notes, and snippets.

@AravindaM
Created July 6, 2015 03:23
Show Gist options
  • Save AravindaM/a7406b05d06db0eb6588 to your computer and use it in GitHub Desktop.
Save AravindaM/a7406b05d06db0eb6588 to your computer and use it in GitHub Desktop.
[JAVA] Reading configuration from Property file
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.log4j.Logger;
/**
* Read configurations from property file.
* @author Aravinda.
*
*/
public class ConfigPropertyReader {
private static Properties configProperties;
private static final Logger LOG = Logger.getLogger(ConfigPropertyReader.class);
public static Properties getDbProperties(){
configProperties = new Properties();
try {
LOG.debug(">> Reading database configuration from '/resources/config.properties' ");
InputStream stream = ConfigPropertyReader.class.getResourceAsStream("/config.properties");
configProperties.load(stream);
} catch (IOException e) {
LOG.error(">> Error while reading from config properties",e);
}
return dbProperties;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment