title: How can I access a file in WEB-INF/META-INF in a java web app?
body: <p>So the book I am reading says: </p>
  
  <blockquote>
    <p>Unlike JAR files, the root-level /META-INF directory is not on the
    application classpath. You cannot use the ClassLoader to obtain
    resources in this directory. /WEB-INF/classes/META-INF, however, is on
    the classpath. You can place any application resources you desire in
    this directory, and they become accessible through the ClassLoader.</p>
  </blockquote>
  
  <p>And currently under WEB-INF directory I have a META-INF directory and a file called: test.txt.</p>
  
  <p>How can I read this file <strong>using the ClassLoader</strong> ? </p>
  
  <p>I have tried this: </p>
  
  <pre><code>URL resource = this.getClass().getClassLoader().getResource("test.txt");
  System.out.println(resource);
  </code></pre>
  
  <p>But this returns null.</p>
  
  <p>I know the file can be read like: </p>
  
  <pre><code>InputStream resourceContent = getServletContext().getResourceAsStream("/WEB-INF/META-INF/test.txt");
  System.out.println(resourceContent);
  </code></pre>
  
  <p>but this is not I want. I want to understand the ClassLoader..</p>
  
  <p>Thanks.</p>