Monday, August 31, 2009

Loading Properties from a file in class path

A simple and smart way of loading a properties file which is located some where in the classpath

-------------------------

InputStream in = null;

Properties m_Properties = null;

in = ClassLoader.getSystemClassLoader().getResourceAsStream(fileName);

if (in != null)
{
m_Properties = new Properties ();

try {

m_Properties.load (in);

}

catch (IOException e)
{
e.printStackTrace();
}
}