title: Read directory inside JAR with InputStreamReader
body: <p>So, this question has been asked a million times i believed and I've been reading them for a couple of hours and trying several options given by some people but none of them work for me.</p>
  
  <p>I want to list all the files inside a directory inside the application's JAR, so in IDE this works:</p>
  
  <pre><code>File f = new File(this.getClass().getResource("/resources/").getPath());
  
  for(String s : f.list){
     System.out.println(s);
  }
  </code></pre>
  
  <p>That gives me all the files inside the directory.</p>
  
  <p>Now, i've tried this also:</p>
  
  <pre><code>InputStream in = this.getClass().getClassLoader().getResourceAsStream("resources/");
      InputStreamReader inReader = new InputStreamReader(in);
      Scanner scan = new Scanner(inReader);
  
      while (scan.hasNext()) {
          String s = scan.next();
          System.out.println("read: " + s);
      }
  
      System.out.println("END OF LINE");
  </code></pre>
  
  <p>And from IDE it prints ALL the files in the directory. Outside IDE prints: "END OF LINE".</p>
  
  <p>Now, I can find an entry inside a Jar with this too:</p>
  
  <pre><code>        String s = new File(this.getClass().getResource("").getPath()).getParent().replaceAll("(!|file:\\\\)", "");
          JarFile jar = new JarFile(s);
  
              JarEntry entry = jar.getJarEntry("resources");
  
          if (entry != null){
              System.out.println("EXISTS");
              System.out.println(entry.getSize());
          }
  </code></pre>
  
  <p>That's some horrible coding i had to do to that String. </p>
  
  <p>Anyway... I can't get the list of resources inside the "resources" directory within the Jar... How can I do this???</p>