title: Loading application.properties file to java.util.Properties in Spring Boot
body: <p>I read through the Spring Boot documentation for <a href="http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html" rel="nofollow">externalized configuration</a> and I see that it automatically loads the src/main/resources/application.properties file which can be then wired to the bean properties using annotation. </p>
  
  <p>However I want to have a generic <code>PropertyHelper</code> class which can be used to build the <code>java.util.Properties</code> with the properties in application.properties. Can this be done?</p>
  
  <p>We are currently achieving this manually as below:</p>
  
  <pre><code>public class PropertyHelper {
  
      private static Properties loadProperties() {
          try {
  
               String propsName = "application.properties";
               InputStream propsStream = PropertyHelper.class
                      .getClassLoader().getResourceAsStream(propsName);
              if (propsStream == null) {
                  throw new IOException("Could not read config properties");
              }
  
              Properties props = new Properties();
              props.load(propsStream);
  </code></pre>