title: Groovy: Preferred Way to Handle Classpath Resource Loading
body: <p>From my initial research I've found that I can load classpath resources in groovy by the following approaches:</p>
  
  <ol>
  <li>this.getClass().getClassLoader.getResourceAsStream(resourceName)</li>
  <li>ClasspathResourceManager (for which I couldn't find any examples)</li>
  </ol>
  
  <p>So, I wanted to seek opinions on what is the most 'groovy' way of handling classpath resources?</p>
  
  <p>Further more, I have a list of '*.xsd' files under and 'xsd' directory inside my jar. Is there anyway I can do something similar to this, but with classpath resources?</p>
  
  <pre><code>List&lt;StreamSource&gt; schemaDefinitions = new File('src/main/resources/xsd')
    .listFiles( { dir, file -&gt; file ==~ /.*\.xsd/ } as FilenameFilter )
    .collect { new StreamSource(it) }
  
  // Looking for something like this:
  List&lt;StreamSource&gt; schemaDefinitions = this.getClass().getResource('src/main/resources/xsd')
    .listFiles( { dir, file -&gt; file ==~ /.*\.xsd/ } as FilenameFilter )
    .collect { new StreamSource(it) }
  </code></pre>
  
  <p>Thanks!</p>