code: public static void writeTextFile(String text,File file) throws IOException
      {
          Writer writer=null;
          try
          {
              //create writer to file (with default encoding)
              OutputStream outputStream=new FileOutputStream(file);
              writer=IOHelper.createWriter(outputStream,null);
              
              //write to file
              writer.write(text);
          }
          finally
          {
              //close writer
              IOHelper.closeResource(writer);
          }
      }
docs: Writes the text to the file.
  
  @param   text
  The text to write to the provided file
  @param   file
  The text file
  @throws  IOException
  Any IO exception