Merge two files

// IO Streams
// File handling
// Merge 2 files
 
import java.io.*;
 
class FileMerge
{
     public static void main(String as[]) throws IOException
     {
          FileInputStream fin1 = new FileInputStream(“F1.txt”);
          FileInputStream fin2 = new FileInputStream(“F2.txt”);
         
          FileOutputStream fout = new FileOutputStream(“F3.txt”);
         
          while(true)
          {
              int i = fin1.read();
              if(i==-1)
                   break;
              fout.write((char)i);              
          }
         
          while(true)
          {
              int i = fin2.read();
              if(i==-1)
                   break;
              fout.write((char)i);              
          }
         
          fout.close();
          fin1.close();
          fin2.close();
         
     }
}