Saturday, 14 May 2016

file handling in java

how to create a backup file 
import java.io.*;
class BakFileCreator
{
 
   public static void main(String args[]) throws FileNotFoundException,IOException
    {
    FileInputStream fis=new FileInputStream(args[0]);
  
    FileOutputStream fos=new FileOutputStream(args[0]+".bak");
  
  
   
   int data;
  while((data=fis.read())!=-1)
{
   fos.write(data);
}
System.out.println("backup file is success fully created");

 
}//main
}//class

output

 

No comments:

Post a Comment