title: How do I access the content of folders inside a jar file?
body: <p>I need to take a look at the names of files inside a specific package. Currently, I'm doing the following:</p>
  
  <pre><code>ClassLoader loader = Thread.currentThread().getContextClassLoader();
  URL packageUrl = loader.getResource(getPackage().replace('.', '/'));
  File packageDir = new File(packageUrl.getFile());
  
  // Work with the files inside the directory
  </code></pre>
  
  <p>This actually works just fine in Eclipse, since it doesn't package my application by default. When I run it from a jar file, however, I get a <code>NullPointerException</code> on <code>packageUrl</code>.</p>
  
  <p>So, how do I obtain a list of the contents of a package that's inside a jar? My research suggested using <code>getResourceAsStream</code>, but I'm not quite sure how to explore a directory with an <code>InputStream</code>, if that's even possible.</p>