by Dinesh Thakur

 

import java.io.*;

class CopyingContentsJavaExample
{
      public static void main(String args[]) throws IOException
      {
             int i;
             FileOutputStream hh;
             FileInputStream fp;
             try
              {
                  fp=new FileInputStream(args[0]);
              }
                  catch(FileNotFoundException e)
                        {
                            System.out.println("File Can not be Found");
                            return;
                        }
                             try
                               {
                                   hh=new FileOutputStream(args[1]);
                               }
                                  catch(IOException e)
                                         {
                                            System.out.println("File Cannot be Found");
                                            return;
                                         }
                                             do
                                                {
                                                    i=fp.read();
                                                    if(i !=-1)
                                                       {
                                                           hh.write(i);
                                                           System.out.print((char)i);
                                                        }
                                                }while(i !=-1);
                                                           fp.close();
                                                           hh.close();
      }
 }