title: Loading resources from multiple folders in Spring using resourceLoader
body: <p>This question is in reference with another stackoverflow post - <a href="https://stackoverflow.com/questions/27238746/how-to-load-all-files-of-a-folder-to-a-list-of-resources-in-spring">How to load all files of a folder to a list of Resources in Spring?</a></p>
  
  <p>I want to load all files from two specific folders using ResourceLoader. I am trying to use ResourcePatternUtils. </p>
  
  <p>class Foobar {
      private ResourceLoader resourceLoader;</p>
  
  <pre><code>@Autowired
  public Foobar(ResourceLoader resourceLoader) {
      this.resourceLoader = resourceLoader;
  }
  
  Resource[] loadResources(String pattern) throws IOException {
      return ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources(pattern);
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>Resource[] resources1 = foobar.loadResources("classpath*:../../folder1/*.txt");
  Resource[] resources2 = foobar.loadResources("classpath*:../../folder2/*.txt");
  </code></pre>
  
  <p>But I need both the resources in a single array. Should I be using something like Java8 stream to concatenate them ?</p>