/*                                      
 * SimpleTextCopy.java 
 *
 * Version: 
 *     $Id: SimpleTextCopy.java,v 1.1 2002/03/22 18:34:38 jmg Exp $ 
 * 
 * Revisions: 
 *     $Log: SimpleTextCopy.java,v $
 *     Revision 1.1  2002/03/22 18:34:38  jmg
 *     Initial revision
 * 
 */

// We need classes from the Java I/O package
import java.io.*;

/**
 * Class that performs a simple copy from one text file to another
 *
 * @author Joe Geigel
 */
public class SimpleTextCopy {
    /**
     * main program.  Takes two filenames as arguments.  The first
     * is the name of the source file, the second is the name of the 
     * destination file
     */
    public static void main (String args[])
    {
	// Commandline check
	if (args.length != 2) {
	    System.out.println 
		("usage: java SimpleTextCopy <source> <destination>");
	    System.exit(1);
	}

	// Remember that most IO operations will throw an IOException
	// if things go wrong
	try {
	    FileReader fin = new FileReader (args[0]);
	    FileWriter fout = new FileWriter (args[1]);
	    
	    int n=0;
	    while ((n = fin.read()) != -1) 
		fout.write (n);

	    fin.close();
	    fout.close();
	}
	catch (IOException E){
	    System.out.println ("Problem: " + E.getMessage());
	}
    }
}
