//This will copy a file, with lots of error handling code
//Usage: FileCopy SourceFile DestinationFile
//By Neil Broadbent

import java.io.*;
import java.util.StringTokenizer;
import NeilClass.*;
import java.awt.*;

public class FileCopyEC
{
    public static void main(String[] pArgs) throws IOException
        {
		if(pArgs.length!=2)
		{
			System.out.println("Error, No files or wrong number of files specified");
			System.out.println("Usage: FileCopyEC SourceFile DestinationFile");
			System.exit(1);
		}
		

		String oneLine;
		String[] aStore = new String [100];
		int i = 0;
		int Return=-1;	
		File filen = new File(pArgs[0]); 
		
		try
		{
			FileInputStream theFile = new FileInputStream(pArgs[0]);

			int FileSize =(int)filen.length();
			byte Bytes[]=new byte[FileSize];
			Return=theFile.read(Bytes);
		
			String file1 = new String(Bytes);
			System.out.println(file1);

			FileOutputStream myOutput = new FileOutputStream(pArgs[1]);

			for (int loop = i; i<FileSize; i++)
			{
				myOutput.write(Bytes[i]);
			}		
				myOutput.close();


		}
		catch( FileNotFoundException e )
		{
			System.out.println("The file was not found");
		}
		catch(Exception e)
		{
			System.out.println( e );
			System.out.println("The above error was generated by the program");
		}


        }

}

