public static String[] listResources(String quoteDirectoryUnquote) throws URISyntaxException, IOException {
  final String dirWithSlash=trailingSlash(quoteDirectoryUnquote,true);
  final URL url;
  URL temp=getResource(dirWithSlash);
  if (temp == null) {
    temp=getResource(trailingSlash(quoteDirectoryUnquote,false));
  }
  url=temp;
  if (url == null) {
    return null;
  }
  if (url.getProtocol().equals("file")) {
    final ArrayList<String> strings=new ArrayList<>();
    final File dir=new File(url.toURI());
    for (    final File f : FileUtils.listFiles(dir)) {
      strings.add(StringUtils.FS.equals("/") ? f.getPath() : f.getPath().replaceAll("\\\\" + StringUtils.FS,"/"));
    }
    return strings.toArray(new String[strings.size()]);
  }
 else   if (url.getProtocol().equals("jar")) {
    final ArrayList<String> strings=new ArrayList<>();
    assert url.getPath().startsWith("file:");
    final String jarPath=url.getPath().substring(5,url.getPath().lastIndexOf('!'));
    try (JarFile jf=new JarFile(jarPath)){
      final Enumeration<JarEntry> en=jf.entries();
      while (en.hasMoreElements()) {
        final JarEntry je=en.nextElement();
        if (je.getName().startsWith(dirWithSlash)) {
          final String rest=je.getName().substring(dirWithSlash.length());
          final int index=rest.indexOf('/');
          if (rest.length() > 0 && (index < 0 || (index > 0 && index == rest.length() - 1))) {
            strings.add(je.getName());
          }
        }
      }
    }
     return strings.toArray(new String[strings.size()]);
  }
  return null;
}

public static String [ ] listResources ( String quoteDirectoryUnquote ) throws URISyntaxException , IOException { final String dirWithSlash = trailingSlash ( quoteDirectoryUnquote , true ) ; final URL url ; URL temp = getResource ( dirWithSlash ) ; if ( temp == null ) { temp = getResource ( trailingSlash ( quoteDirectoryUnquote , false ) ) ; } url = temp ; if ( url == null ) { return null ; } if ( url . getProtocol ( ) . equals ( "file" ) ) { final ArrayList < String > strings = new ArrayList < > ( ) ; final File dir = new File ( url . toURI ( ) ) ; for ( final File f : FileUtils . listFiles ( dir ) ) { strings . add ( StringUtils . FS . equals ( "/" ) ? f . getPath ( ) : f . getPath ( ) . replaceAll ( "\\\\" + StringUtils . FS , "/" ) ) ; } return strings . toArray ( new String [ strings . size ( ) ] ) ; } else if ( url . getProtocol ( ) . equals ( "jar" ) ) { final ArrayList < String > strings = new ArrayList < > ( ) ; assert url . getPath ( ) . startsWith ( "file:" ) ; final String jarPath = url . getPath ( ) . substring ( 5 , url . getPath ( ) . lastIndexOf ( '!' ) ) ; try ( JarFile jf = new JarFile ( jarPath ) ) { final Enumeration < JarEntry > en = jf . entries ( ) ; while ( en . hasMoreElements ( ) ) { final JarEntry je = en . nextElement ( ) ; if ( je . getName ( ) . startsWith ( dirWithSlash ) ) { final String rest = je . getName ( ) . substring ( dirWithSlash . length ( ) ) ; final int index = rest . indexOf ( '/' ) ; if ( rest . length ( ) > 0 && ( index < 0 || ( index > 0 && index == rest . length ( ) - 1 ) ) ) { strings . add ( je . getName ( ) ) ; } } } } return strings . toArray ( new String [ strings . size ( ) ] ) ; } return null ; }
list resources within a & quot ; directory & quot ; . < p > note : output can be problematic when path exists in multiple locations .
