title: Using ClassLoader.getSystemResource to get file path in JAVA
body: <p>I'm writing a dynamic web module using Tomcat 7 with Eclipse and Java 8, and my problem is that a required JAVA project on the build path is using the following to load files (lexicons, dictionaries, etc):</p>
  
  <pre><code>String filePath = "conf/test.txt"; // my test file is in WEB-INF/conf
  String absolutePath = ClassLoader.getSystemResource(filePath).getPath();
  </code></pre>
  
  <p>I'm getting a null pointer so it's not finding the file.</p>
  
  <p>When using the following, it finds the file:</p>
  
  <pre><code>String absolutePath = new File(filePath).getAbsolutePath();
  </code></pre>
  
  <p><strong>The problem is</strong>:</p>
  
  <p>I am required to use <code>ClassLoader.getSystemResource</code>. How can I specify my file's path for it to work without getting a null pointer (without using absolute paths too)?</p>