import java.io.File;

public class Main {
public static void main(String[] argv) {
// Rename oldfile.txt to newfile.txt
File oldFile = new File(“oldfile.txt”);
File newFile = new File(“newfile.txt”);

boolean filRenam = oldFile.renameTo(newFile);
if (filRenam) {
System.out.println(oldFile + ” renamed to ” + newFile);
} else {
System.out.println(“Renaming ” + oldFile + ” to ” + newFile
+ ” failed.”);
}

}
}

Your Answer
Sign In
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.