title: Accessing files in specific folder in classpath using Java - works only for single file
body: <p>I'm trying to get a list of resources from classpath directory. I'm using JDK 1.7 on Mac OS X. I'm using response to <a href="https://stackoverflow.com/questions/13848333/accessing-files-in-specific-folder-in-classpath-using-java">this question</a> to solve my problem. I can open and read a single file, however when I try to read whole directory I get empty list of files.</p>
  
  <p>This works:</p>
  
  <pre><code>InputStream is = loadFile("scenes/test.xml");
  InputStreamReader sReader = new InputStreamReader(is);
  BufferedReader bReader = new BufferedReader(sReader);
  System.out.println(bReader.readLine()); // print "&lt;Empty/&gt;"
  </code></pre>
  
  <p>loadFile method looks that way:</p>
  
  <pre><code>private InputStream loadFile(String filePath) throws IOException {
      InputStream inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
      if (inStream == null) {
          throw new IOException("Unable to load file from resources " + filePath);
      }
      return inStream;
  }
  </code></pre>
  
  <p>and this doesn't</p>
  
  <pre><code>InputStream is = loadFile("scenes/");
  InputStreamReader sReader = new InputStreamReader(is);
  BufferedReader bReader = new BufferedReader(sReader);
  System.out.println(bReader.readLine()); // print "null"
  </code></pre>
  
  <p>Anyone can help with this problem?</p>