Turn Desktop View Off
by Dinesh Thakur

We use two classes FileInputStream, FileOutputStream i.e to read data from one file and write it to another file.

Here is the Java Example for Copy Data From One File to Another:

import java.io.*;

class CopyDataFiletoFile
{
             public static void main(String args[])throws IOException
        {
              FileInputStream Fread =new FileInputStream("Hello.txt");
              FileOutputStream Fwrite=new FileOutputStream("Hello1.txt") ;
              System.out.println("File is Copied");
              int c;
              while((c=Fread.read())!=-1)
              Fwrite.write((char)c);
              Fread.close();
              Fwrite.close();
         }
}

 

Copy Data From One File to Another File