   import java.util.*;
   import java.io.*;
/** 
 * A small class to play with I/O
 *
 * @author Nancy Harris
 * @version V1
 */
    public class IO
   {
   /** 
    * Main method to create a copy of a text file
    *
    * @param args Command line arguments, unused
    */
       public static void main(String args[]) 
		 						throws FileNotFoundException
		 {
         File 			inFile, outFile;
         Scanner 		reader;
         PrintWriter writer;
         String 		holder;
      
      	// instantiate the "files"
         inFile = new File("myText.txt");
         outFile = new File("copyText.txt");
      
			reader = null;
         try
         {
            reader = new Scanner(inFile);
         }
          catch(FileNotFoundException fnfe)
         {
            System.out.println("Bad file name - exiting");
            System.exit(1);
         }
      	writer = null;
         try  
         {    
            writer = new PrintWriter(outFile);
         }	
         catch(FileNotFoundException fnfe)
         {
            System.out.println("Bad output file name - exiting");
				System.exit(0);
			}
   		catch(IOException ioe)
			{
				System.out.println("Cannot access output file - exiting");
				System.exit(0);
			}
         
			while(reader.hasNext())
         {
            holder = reader.nextLine();
            writer.println(holder);
         }
      	// Exiting the program will automatically close
			// the files, but explicit closes free resources
         reader.close();
         writer.close();
      }
   }
