JAVA Program to Copy File Byte by Byte

JAVA Program to Copy File Byte by Byte:


import java.io.*;
class cpyfile
{
 public static void main(String args[])throws IOException
 {
  int i;
  FileInputStream f1;
  FileOutputStream f2;
  try
  {
   f1=new FileInputStream(args[0]); //Command Line
   f2=new FileOutputStream(args[1]); //Command Line

   do
   {
    i=f1.read();
    if(i!=-1)
    f2.write(i);
   }
   while(i!=-1);
   System.out.println("Sucessful");
}
 catch(Exception e)
 {
    System.out.println("Can't copy" +e);
 }
}
}

Leave a Reply

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

five × two =

This site uses Akismet to reduce spam. Learn how your comment data is processed.