title: How to load file from resources directory in Java
body: <p>I am trying to load a properties file directly from the resources directory of my Java project and am getting a null pointer exception. Can someone pl explain how to do it? </p>
  
  <p>Code- </p>
  
  <pre><code>String resourceName = "config-values.properties"; 
  Properties props = new Properties();
  try(InputStream resourceStream = getClass().getClassLoader().getResourceAsStream(resourceName)) {
              props.load(resourceStream);
          }
  </code></pre>
  
  <p>My folder structure is - /src/packageName and /src/resources/</p>