title: Writing a groovy script results into a file
body: <p>I would like to write groovy script results in to a file on my Mac machine.
  How do I do that in Groovy?
  Here my attempt:</p>
  
  <pre><code>log.info "Number of nodes:" + numElements
  log.info ("Matching codes:"+matches)
  log.info ("Fails:"+fails)
  
  // Exporting results to a file
  today = new Date()
  sdf = new java.text.SimpleDateFormat("dd-MM-yyyy-hh-mm")
  todayStr = sdf.format(today)
  new File( "User/documents" + todayStr + "report.txt" ).write(numElements, "UTF-8" )
  new File( "User/documents" + todayStr + "report.txt" ).write(matches, "UTF-8" )
  new File( "User/documents" + todayStr + "report.txt" ).write(fails, "UTF-8" )
  </code></pre>
  
  <p>Can anyone help in the exporting results part?</p>
  
  <p>Thanks,
  Regards,
  A
  ok, i've managed to create a file with </p>
  
  <pre><code>file = new File(dir + "${todayStr}_report.txt").createNewFile()
  </code></pre>
  
  <p>How do I add the numelements,matches and fails? like this:</p>
  
  <pre><code> File.append (file, matches)? 
  </code></pre>
  
  <p>I get the follwoing error:</p>
  
  <pre><code>groovy.lang.MissingMethodException: No signature of method: static java.io.File.append() is applicable for argument types: (java.lang.Boolean, java.util.ArrayList) values: [true, [EU 4G FLAT L(CORPORATE) SP, EU 4G FLAT M(CORPORATE), ...]] Possible solutions: append(java.lang.Object, java.lang.String), append(java.io.InputStream), append(java.lang.Object), append([B), canRead(), find() error at line: 33
  </code></pre>