/**
 * CopyFile.java
 * 
 * Illustrates the use of a Scanner and a PrintStream object to create
 * a copy of a text file.
 */

import java.util.*;  // needed for Scanner
import java.io.*;    // needed for File

public class CopyFile {
    public static void main(String[] args) throws FileNotFoundException {
       Scanner console = new Scanner(System.in);
       System.out.print("Name of original file: ");
       String original = console.next();
       System.out.print("Name of copy: ");
       String copy = console.next();

       // This Scanner will read from the original file.
       Scanner input = new Scanner(new File(original));
       
       // This PrintStream object will write to the copy.
       PrintStream output = new PrintStream(new File(copy));

       while (input.hasNextLine()) {
            String line = input.nextLine();
            output.println(line);
        }
    }
}