title: How can I iterate entries in a URL resource pointing to a folder in a JAR
body: <p>I have a situation where an app I'm writing works fine from the IDE but fails when deployed into a jar.  What I see is NULL pointer exception.  What I'm trying to do is get a URL resource of a directory and then iterate through the files in that directory.  The URL seems to work but I can't find a way to get the files from it.</p>
  
  <p>So I can't seem to get a file list (because this is really a resouce list inside the jar).</p>
  
  <p>Any ideas?</p>
  
  <p>TIA</p>
  
  <pre><code>        URL scriptFolder = getClass().getResource("/scripts/");
          log.debug(scriptFolder);
  
          if (scriptFolder != null) {
              File folder = new File(scriptFolder.getFile());
              File[] files = folder.listFiles();
              // files is NULL here.
              for (int i = 0; i &lt; files.length; i++) {
                  if (files[i].isFile()) {
                      log.debug("File " + files[i].getName());
                  }
              }
          }
  </code></pre>