@@ -0,0 +1,1114 @@
+/* Copy a text file.%0A%0A%09To use this program, specify the name of the source file and the destination file.%0A%09%0A%09For example, to copy a file called FIRST.TXT to a file called SECOND.TXT, use the following command line.%0A%09%0A%09java CopyFile FIRST.TXT SECOND.TXT%0A*/%0A%0Aimport java.io.*;%0A%0Aclass CopyFile %7B%0A%09public static void main(String args%5B%5D) throws IOException %7B%0A%09%09int i;%0A%09%09FileInputStream fin;%0A%09%09FileOutputStream fout;%0A%09%09%0A%09%09try %7B%0A%09%09%09// open input file%0A%09%09%09try %7B%0A%09%09%09%09fin = new FileInputStream(args%5B0%5D);%0A%09%09%09%7D catch(FileNotFoundException exc) %7B%0A%09%09%09%09System.out.println(%22Input File Not Found%22);%0A%09%09%09%09return;%0A%09%09%09%7D%0A%09%09%09%0A%09%09%09// open output file%0A%09%09%09try %7B%0A%09%09%09%09fout = new FileOutputStream(args%5B1%5D);%0A%09%09%09%7D catch(FileNotFoundException exc) %7B%0A%09%09%09%09System.out.println(%22Error Opening Output File%22);%0A%09%09%09%09return;%0A%09%09%09%7D%0A%09%09%7D catch(ArrayIndexOutOfBoundsException exc) %7B%0A%09%09%09System.out.println(%22Usage: CopyFile From To%22);%0A%09%09%09return;%0A%09%09%7D%0A%09%09%0A%09%09// Copy File%0A%09%09try %7B%0A%09%09%09do %7B%0A%09%09%09%09i = fin.read();%0A%09%09%09%09if(i != -1) fout.write(i);%0A%09%09%09%7D while(i != -1);%0A%09%09%7D catch(IOException exc) %7B%0A%09%09%09System.out.println(%22File Error%22);%0A%09%09%7D%0A%09%09%0A%09%09fin.close();%0A%09%09fout.close();%0A%09%7D%0A%7D%0A

Copy a text file