how to rename a java file code example
Example: How to rename file in java
// rename file in java example
import java.io.*;
public class RenameFile
{
public static void main(String[] args) throws IOException
{
File oldFile = new File("D:\\Project\\flower.txt");
File newFile = new File("D:\\Project\\flowerbrackets.txt");
if(oldFile.renameTo(newFile))
{
System.out.println("Rename successful");
}
else
{
System.out.println("Rename failed");
}
}
}