JAVA Program to Copy File Character by Character

JAVA Program to Copy File Character by Character:


/* CHARACTER BY CHARACTER COPY FILE*/
import java.io.*;
class filecopy
{
 public static void main(String args[])
 {
   File i=new File("png.txt");
   File o=new File("efg.txt");

   FileReader fr=null;
   FileWriter fw=null;

  try
  {

   fr=new FileReader(i);
   fw=new FileWriter(o);
   int ch;

   while((ch=fr.read())!=-1)
   {
      fw.write(ch);
   }
  }
  catch(Exception e){}

  finally
  {
      try
      {
   fr.close();
   fw.close();
}
catch(Exception e){}
  }
 }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

five × four =