src/main/java/org/lightcouch/CouchDbUtil.java
public static List<String> listResources(String path)  {
		try {
			Class<CouchDbUtil> clazz = CouchDbUtil.class;
			URL dirURL = clazz.getClassLoader().getResource(path);
			if (dirURL != null && dirURL.getProtocol().equals("file")) {
				return Arrays.asList(new File(dirURL.toURI()).list());
			}
			if (dirURL != null && dirURL.getProtocol().equals("jar")) {
				String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf("!")); 
				JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"));
				Enumeration<JarEntry> entries = jar.entries(); 
				Set<String> result = new HashSet<String>(); 
				while(entries.hasMoreElements()) {
					String name = entries.nextElement().getName();
					if (name.startsWith(SPRING_BOOT_DIR)) {
						name = name.substring(SPRING_BOOT_DIR.length());
					}
					if (name.startsWith(path)) { 
						String entry = name.substring(path.length());
						int checkSubdir = entry.indexOf("/");
						if (checkSubdir >= 0) {
							entry = entry.substring(0, checkSubdir);
						}
						if(entry.length() > 0) {
							result.add(entry);
						}
					}
				}
				close(jar);
				return new ArrayList<String>(result);
			} 
			return null;
		} catch (Exception e) {
			throw new CouchDbException(e);
		}
	}
public static List<String> listResources(String path)  {
		try {
			Class<CouchDbUtil> clazz = CouchDbUtil.class;
			URL dirURL = clazz.getClassLoader().getResource(path);
			if (dirURL != null && dirURL.getProtocol().equals("file")) {
				return Arrays.asList(new File(dirURL.toURI()).list());
			}
			if (dirURL != null && dirURL.getProtocol().equals("jar")) {
				String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf("!")); 
				JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"));
				Enumeration<JarEntry> entries = jar.entries(); 
				Set<String> result = new HashSet<String>(); 
				while(entries.hasMoreElements()) {
					String name = entries.nextElement().getName();
					if (name.startsWith(SPRING_BOOT_DIR)) {
						name = name.substring(SPRING_BOOT_DIR.length());
					}
					if (name.startsWith(path)) { 
						String entry = name.substring(path.length());
						int checkSubdir = entry.indexOf("/");
						if (checkSubdir >= 0) {
							entry = entry.substring(0, checkSubdir);
						}
						if(entry.length() > 0) {
							result.add(entry);
						}
					}
				}
				close(jar);
				return new ArrayList<String>(result);
			} 
			return null;
		} catch (Exception e) {
			throw new CouchDbException(e);
		}
	}
public static List < String > listResources ( String path ) { try { Class < CouchDbUtil > clazz = CouchDbUtil . class ; URL dirURL = clazz . getClassLoader ( ) . getResource ( path ) ; if ( dirURL != null && dirURL . getProtocol ( ) . equals ( "file" ) ) { return Arrays . asList ( new File ( dirURL . toURI ( ) ) . list ( ) ) ; } if ( dirURL != null && dirURL . getProtocol ( ) . equals ( "jar" ) ) { String jarPath = dirURL . getPath ( ) . substring ( 5 , dirURL . getPath ( ) . indexOf ( "!" ) ) ; JarFile jar = new JarFile ( URLDecoder . decode ( jarPath , "UTF-8" ) ) ; Enumeration < JarEntry > entries = jar . entries ( ) ; Set < String > result = new HashSet < String > ( ) ; while ( entries . hasMoreElements ( ) ) { String name = entries . nextElement ( ) . getName ( ) ; if ( name . startsWith ( SPRING_BOOT_DIR ) ) { name = name . substring ( SPRING_BOOT_DIR . length ( ) ) ; } if ( name . startsWith ( path ) ) { String entry = name . substring ( path . length ( ) ) ; int checkSubdir = entry . indexOf ( "/" ) ; if ( checkSubdir >= 0 ) { entry = entry . substring ( 0 , checkSubdir ) ; } if ( entry . length ( ) > 0 ) { result . add ( entry ) ; } } } close ( jar ) ; return new ArrayList < String > ( result ) ; } return null ; } catch ( Exception e ) { throw new CouchDbException ( e ) ; } }
List directory contents for a resource folder. Not recursive.
This is basically a brute-force implementation.
Works for regular files and also JARs.

@author Greg Briggs
@param path Should end with "/", but not start with one.
@return Just the name of each member item, not the full paths.
List directory contents for a resource folder . Not recursive . This is basically a brute - force implementation . Works for regular files and also JARs .