title: List Files from Templates Directory in Spring Boot
body: <p>I would like to generate a blog posts overview. For that I want to read the html files from a folder inside the templates folder in the resources folder where Spring Boot stores its templates.</p>
  
  <p>I tried that but it doesnt return an error but also list no files.</p>
  
  <p>What is the way to go here?</p>
  
  <p>Thanks</p>
  
  <pre><code>@Controller
  public class Route {
  
      @Autowired
      private ResourceLoader resourceLoader;
  
      @RequestMapping("/")
      public String home() throws IOException {
          final String path = "templates/blog";
          final Resource res = resourceLoader.getResource("templates/blog");
          try (final BufferedReader reader = new BufferedReader(new InputStreamReader(res.getInputStream()))) {
              reader.lines().forEachOrdered(System.out::println);
          }
          return "blog/a";
      }
  }
  </code></pre>