title: Find a resource (.txt file) in war file which is deployed standalone or in ear
body: <p>I have a war file is packaged in ear and deployed. Here is the structure:</p>
  
  <pre><code>EAR
  -WAR
  --input.txt
  --META-INF
  --WEB-INF
  ---classes
  (and so on)
  </code></pre>
  
  <p>I am trying to read <strong>input.txt</strong> from one of the classes (say abc.xyz.Myclass) in WEB-INF/classes folder. Here is what I tried:</p>
  
  <pre><code>this.getClass().getClassLoader().getResourceAsStream("../../input.txt");
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Thread.currentThread().getContextClassLoader().getResourceAsStream("../../input.txt");
  </code></pre>
  
  <p>I tried several paths like "../input.txt" or "/input.txt" or just "input.txt" by attaching a debugger. But every time I am getting NULL as return value (means it is not able to find the file).</p>
  
  <p>What is the correct way to access that file in war irrespective of whether war is deployed standalone or it is packed in ear? Please help.</p>