@Test public void test() throws Exception { final List<URL> urls = Classpaths.classpathResources( this.getClass(), "testfile.txt" ); URL url = urls.get( 0 ); boolean ok = true; ok |= Str.in( "apple", IO.read( url.openStream() ) ) || die(); }
public static List<URL> classpathResources( ClassLoader loader, String resource ) { try { Enumeration<URL> resources = loader.getResources( resource ); List<URL> list = list( resources ); if ( isEmpty( list ) && resource.startsWith( "/" ) ) { resource = resource.substring( 1 ); return classpathResources( loader, resource ); } return list; } catch ( Exception ex ) { return Exceptions.handle( List.class, sputs( "Unable to load listFromClassLoader for", resource ), ex ); } }
Classpaths { public static List<URL> classpathResources( ClassLoader loader, String resource ) { try { Enumeration<URL> resources = loader.getResources( resource ); List<URL> list = list( resources ); if ( isEmpty( list ) && resource.startsWith( "/" ) ) { resource = resource.substring( 1 ); return classpathResources( loader, resource ); } return list; } catch ( Exception ex ) { return Exceptions.handle( List.class, sputs( "Unable to load listFromClassLoader for", resource ), ex ); } } }
Classpaths { public static List<URL> classpathResources( ClassLoader loader, String resource ) { try { Enumeration<URL> resources = loader.getResources( resource ); List<URL> list = list( resources ); if ( isEmpty( list ) && resource.startsWith( "/" ) ) { resource = resource.substring( 1 ); return classpathResources( loader, resource ); } return list; } catch ( Exception ex ) { return Exceptions.handle( List.class, sputs( "Unable to load listFromClassLoader for", resource ), ex ); } }  }
Classpaths { public static List<URL> classpathResources( ClassLoader loader, String resource ) { try { Enumeration<URL> resources = loader.getResources( resource ); List<URL> list = list( resources ); if ( isEmpty( list ) && resource.startsWith( "/" ) ) { resource = resource.substring( 1 ); return classpathResources( loader, resource ); } return list; } catch ( Exception ex ) { return Exceptions.handle( List.class, sputs( "Unable to load listFromClassLoader for", resource ), ex ); } }  static List<URL> classpathResources( ClassLoader loader, String resource ); static List<URL> classpathResources( Class<?> clazz, String resource ); static List<String> resources( Class<?> clazz, String resource ); static List<Path> paths( Class<?> clazz, String resource ); static List<String> listFromClassLoader(ClassLoader loader, String resource); static List<Path> pathsFromClassLoader(ClassLoader loader, String resource); }
Classpaths { public static List<URL> classpathResources( ClassLoader loader, String resource ) { try { Enumeration<URL> resources = loader.getResources( resource ); List<URL> list = list( resources ); if ( isEmpty( list ) && resource.startsWith( "/" ) ) { resource = resource.substring( 1 ); return classpathResources( loader, resource ); } return list; } catch ( Exception ex ) { return Exceptions.handle( List.class, sputs( "Unable to load listFromClassLoader for", resource ), ex ); } }  static List<URL> classpathResources( ClassLoader loader, String resource ); static List<URL> classpathResources( Class<?> clazz, String resource ); static List<String> resources( Class<?> clazz, String resource ); static List<Path> paths( Class<?> clazz, String resource ); static List<String> listFromClassLoader(ClassLoader loader, String resource); static List<Path> pathsFromClassLoader(ClassLoader loader, String resource);  }