title: How to create a file with content and download it with THYMELEAF
body: <p>I'm working on a spring boot project with thymeleaf and I need to create a file and put some lines on it then send it for the user to download it.</p>
  
  <pre class="lang-java prettyprint-override"><code>@PostMapping("/filegenerator")
  public String createFile(@ModelAttribute("page") Page page, Model model) {
      List&lt;String&gt; lines = new ArrayList&lt;String&gt;();
  
      //Some code ..........
  
      lines.forEach(l-&gt;{
          System.out.println(l);
      });
  
      //Here I need to create a file with the List of lines
  
      //And also put some code to download it        
  
      return "filegenerator";
  }
  </code></pre>