/*                                      
 * SimpleTextArrayCopy.java 
 *
 * Version: 
 *     $Id: SimpleTextArrayCopy.java,v 1.1 2002/03/22 18:34:38 jmg Exp $ 
 * 
 * Revisions: 
 *     $Log: SimpleTextArrayCopy.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 using 
 * arrays
 *
 * @author Joe Geigel
 */
public class SimpleTextArrayCopy {
    /**
     * 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 SimpleTextArrayCopy <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 buflen = 80;
	    char buffer[] = new char[buflen];
	    int n;
	    while ((n = fin.read(buffer)) != -1) 
		fout.write (buffer,0,n);

	    fin.close();
	    fout.close();
	}
	catch (IOException E){
	    System.out.println ("Problem: " + E.getMessage());
	}
    }
}
