/*****************************************************************
** YFileWrite - same as FileWrite, except using york package
**
** (c) Scott MacKenzie, 2000                             
******************************************************************/
import york.*;
import java.io.*; // need File class to check if file exists

class YFileWrite
{
   public static void main(String[] args)
   {

      // Let's call the output file 'junk.txt'
      String s = "junk.txt";

      // check if output file exists
      File f = new File(s);
      if (f.exists())
      {
         York.print("Overwrite " + s + " (y/n)? ");
         if(!York.readLine().toLowerCase().equals("y"))
            return;
      }

      // open file for output 
      YorkWriter outFile = new YorkWriter(s);


      // inform the user what to do
      York.println("Enter some text on the keyboard...");
      York.println("(^z to terminate)");

      // read from keyboard, write to file output stream
      String s2;
      while ((s2 = York.readLine()) != null)
         outFile.println(s2);

      // close disk file
      outFile.close(); 
   }
}

