Unbale to delete and rename file
I have written a simple program which allows students to add and drop courses. When a student is dropping a course, I am copying the entire "courses enrolled" file to another file except for the course dropped. Then, I am trying to delete the old file and rename the new file with the old file name. The entire program is working except for the delete and renaming parts. I have given that portion of the code below. Please help.
File deleteFile = new File("coursesEnrolled.txt");
System.err.println("** Deleted " + " **");
File oldFile = new File("temp.txt");