Created
July 6, 2015 03:23
-
-
Save AravindaM/a7406b05d06db0eb6588 to your computer and use it in GitHub Desktop.
[JAVA] Reading configuration from Property file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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