title: Java read a folder from project base directory
body: <p>I have a maven project with typical project structure. At the base of the project, I have a directory names <strong>res</strong> that has some resources (> 500 MB).
  I am trying to use</p>
  
  <p><code>this.class().getClassLoader().getResourceAsStream("res/xxx")</code></p>
  
  <p>this code fragment to read from that folder, but it returns a null resource stream.
  I have a few workarounds below, but none of these are acceptable due to reasons explained below.</p>
  
  <ol>
  <li>I can move the folder to {base}/target/classes, and it will be read, but it will also get cleaned when I do a <strong>mvn clean</strong>. Hence, this approach doesn't work. For some reason, specifying the path as <strong>../../res/xxx</strong> also doesn't work.</li>
  <li>I can move the folder to {base}/src/resources, but then it will get copied to target/classes and the jar. Hence this is also not acceptable.</li>
  <li>Though I am open to trying some other java APIs, I may have to use the class loader mechanism only as there is some external library component that is also trying to access the <strong>res</strong> folder using the similar approach. </li>
  </ol>
  
  <p>Is there some way I can read the <strong>res</strong> folder from projects base directory? Is there some setting in <strong>pom.xml</strong> file that can help me with that?</p>