Program to copy content of one file to another
existing file
import java.io.*;
public class jonitafilecopy {
public static void main(String[] args)
{

try
{
FileReader fr = new FileReader("pqr.txt");
FileWriter fw = new FileWriter("x.txt");
int k;
while( ( k = fr.read() ) != -1 )
{
fw.write(k);
System.out.print((char) k);
}
fw.close();
fr.close();
}
catch(FileNotFoundException e)
{
System.out.println("File does not exist. " + e);
}
catch(IOException e)
{
System.out.println("Some I/O problem. " + e);
}
}

java copy file program

  • 1.
    Program to copycontent of one file to another existing file import java.io.*; public class jonitafilecopy { public static void main(String[] args) { try { FileReader fr = new FileReader("pqr.txt"); FileWriter fw = new FileWriter("x.txt"); int k; while( ( k = fr.read() ) != -1 ) { fw.write(k); System.out.print((char) k); } fw.close(); fr.close(); } catch(FileNotFoundException e) { System.out.println("File does not exist. " + e); } catch(IOException e) { System.out.println("Some I/O problem. " + e); } }