##########################################################################################
SAMPLE PROPERTY FILE : system.properties
##########################################################################################
##########################################################################################
name=cashyup
passowrd=rukidding
##########################################################################################
##########################################################################################
Java Method to read the property file
##########################################################################################
##########################################################################################
/**
* Load a properties file from the application classpath
* @param propsName Property file name
* @return Properties Properties
* @throws IOException
*/
public static Properties load(final String propsName) throws IOException {
if(LOGGER.isDebugEnabled()){LOGGER.debug("Entry");}
final Properties props = new Properties();
final URL url = ClassLoader.getSystemResource(propsName);
props.load(url.openStream());
if(LOGGER.isDebugEnabled()){LOGGER.debug("Exit");}
return props;
}
##########################################################################################
FIND SPECIFIC PROPERY FROM THE PROPERTY FILE
##########################################################################################
##########################################################################################
Usage: Load properties and find specific property
Properties propMgr = PropertyManager.load("system.properties"); //Loads properties
//Properties propMgr = PropertyManager.load("com/kshan/util/alphabet.properties");
LOGGER.info(propMgr.get("username")); //find a property by key
##########################################################################################