import java.io.*;

/**
   This program demonstrates writing to a file using
   only a FileWriter object.
*/

public class SimpleFileWriter
{
   public static void main(String[] args)
   {
  
      String myOutput = "To thine own self be true.";
      int rawData;        // To hold a character code

      try
      {
         // Open the file.
         FileWriter fwriter = new FileWriter("NewFile.txt");

         // 
         for (int i = 0; i < myOutput.length(); i++)
         {
            // Convert a character to Unicode.
            rawData = (int) myOutput.charAt(i);


            // Write the Unicode.
            fwriter.write(rawData);
         }
         
         // Close the file.
         fwriter.close();
      }
      catch (IOException ioe)
      {
         System.out.println("Error: " +  ioe.getMessage());
      }
   }
}