DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Loading Property Files From Classpath

07.28.2008
| 6529 views |
  • submit to reddit
        // Loading property files from classpath


String sConfigFile = "config/mail.properties";
	
InputStream in = mailSender.class.getClassLoader().getResourceAsStream(sConfigFile);
if (in == null) 
{
	//File not found! (Manage the problem)
}
Properties props = new java.util.Properties();
props.load(in);

Ref : http://snippets.dzone.com/posts/show/813