Finding all CLASSPATH resources matching a pattern
        Posted  
        
            by binil
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by binil
        
        
        
        Published on 2010-05-04T16:06:25Z
        Indexed on 
            2010/05/04
            16:08 UTC
        
        
        Read the original article
        Hit count: 242
        
I want to read a bunch of text files, by loading them as resources using the context classloader.
URL url = Thread.currentThread()
                .getContextClassloader()
                .getResource("folder/foo.txt");
Is there some way to get a list of resources whose names match a given pattern? For eg:
URL[] matchingUrls = someLibrary.getMatchingResources("folder/*.txt");
Libraries like Spring can scan the classpath to find classes with a given annotation, so I am wondering if there something similar to load a bunch of resources.
© Stack Overflow or respective owner