import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
import javax.swing.JOptionPane;
/*
 * FileCopyExample
 *
 * Created on August 31, 2007, 1:08 PM
 *
 * COP 2210 Example
 *
 */

/**
 *
 * @author Bill Kraynek
 */
public class FileCopyExample {
    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        String fileName = JOptionPane.showInputDialog("Enter name of file to copy","src/FileCopyExample.java");
        if( fileName == null ) return;
        Scanner inFile = new Scanner(new File(fileName));
        String copyFileName = JOptionPane.showInputDialog("Enter copy file name","src/FileCopyExampleCopy.java");
        if( copyFileName == null ) return;
        PrintWriter outFile = new PrintWriter(copyFileName);
        while( inFile.hasNext() ) {
            String line = inFile.nextLine();
            outFile.println(line);
        } // end while
        inFile.close();
        outFile.close();
    }
    
}

