// This program reads in two filenames from the keyboard
// and then copies lines from the first file to the second.
// Barry Cornelius, 17 June 2000
import java.io. BufferedReader;
import java.io. BufferedWriter;
import java.io. FileReader;
import java.io. FileWriter;
import java.io. InputStreamReader;
import java.io. IOException;
import java.io. PrintWriter;
public class CopyReadNames
{
   public static void main(final String[] pArgs) throws IOException
   {
      final BufferedReader tKeyboard =
                    new BufferedReader(new InputStreamReader(System.in));
      System.out.print("Type in the name of the input file: ");
      System.out.flush();
      final String tInputFilename = tKeyboard.readLine();
      System.out.print("Type in the name of the output file: ");
      System.out.flush();
      final String tOutputFilename = tKeyboard.readLine();
      iCopyFile(tInputFilename, tOutputFilename); 
   }

   private static void iCopyFile(final String pInputFilename,
                                 final String pOutputFilename)
                                            throws IOException
   {
      final BufferedReader tInputHandle =
                    new BufferedReader(new FileReader(pInputFilename));
      final PrintWriter tOutputHandle =
        new PrintWriter(new BufferedWriter(new FileWriter(pOutputFilename)));
      while (true)
      {
         final String tLine = tInputHandle.readLine();
         if (tLine==null)
         {
            break;
         }
         tOutputHandle.println(tLine);
      }
      tOutputHandle.close();
   }
}
