i've created a file "file1" in java and i read that "file1" and made some changes to the data read from "file1" and i wrote the new data to another file "file2"...now what i need is to delete the previous file "file1" and change the name of the file "file2" to "file1"... please somebody help me with this....
//rename file
File file = new File("oldname");
File file2 = new File("newname");
boolean success = file.renameTo(file2);
//delete file
File f = new File("fileToDelete");
boolean success = f.delete();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With