Never been to DZone Snippets before?

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

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Loading a property file from the classpath

Loads a property file located anywhere in the classpath

   1  
   2      private Properties getPropertiesFromClasspath(String propFileName) throws IOException {
   3          // loading xmlProfileGen.properties from the classpath
   4          Properties props = new Properties();
   5          InputStream inputStream = this.getClass().getClassLoader()
   6              .getResourceAsStream(propFileName);
   7  
   8          if (inputStream == null) {
   9              throw new FileNotFoundException("property file '" + propFileName
  10                  + "' not found in the classpath");
  11          }
  12  
  13          props.load(inputStream);
  14  
  15          return props;
  16      }
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS