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
Loading A Property File From The Classpath
Loads a property file located anywhere in the classpath
private Properties getPropertiesFromClasspath(String propFileName) throws IOException {
// loading xmlProfileGen.properties from the classpath
Properties props = new Properties();
InputStream inputStream = this.getClass().getClassLoader()
.getResourceAsStream(propFileName);
if (inputStream == null) {
throw new FileNotFoundException("property file '" + propFileName
+ "' not found in the classpath");
}
props.load(inputStream);
return props;
}




