title: How to create file in current system from within Grails controller action and save data fetched from database?
body: <p>In my Grails application I need to create a file in current system in which I need to save information fetched from table in database. How to do this from within controller action? I don't have any idea of it.</p>
  
  <p>I have created file as</p>
  
  <pre><code>File file=new File("file name.txt") 
  
  file.createNewFile();
  </code></pre>
  
  <p>then I have wrote values of MySQL database table fields in it as:</p>
  
  <pre><code>file&lt;&lt;patient.id
  file&lt;&lt;patient.name
  .
  .
  .
  </code></pre>
  
  <p>it stores data like continuous text but I want to have a .doc file in which data should get stored in table. I found Apache's POI for creating doc file but I am not getting how it works and how I should use it.</p>