
Write a java program that moves the contents of the one file to another and deletes the old file.

Hi Friend,
Try the following code:
import java.io.*;
class MoveFile{
public static void main(String[] args) throws Exception
{
File f1=new File("C:/data.txt");
File f2=new File("D:/data.txt");
BufferedReader br=new BufferedReader(new FileReader(f1));
BufferedWriter bw=new BufferedWriter(new FileWriter(f2));
String line="";
while((line=br.readLine())!=null){
bw.write(line);
}
bw.close();
br.close();
f1.delete();
System.out.println("File is moved successfully!");
}
}
For more information, visit the following link:
Thanks

Thank U....
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.