1// rename file in java example
2import java.io.*;
3public class RenameFile
4{
5 public static void main(String[] args) throws IOException
6 {
7 File oldFile = new File("D:\\Project\\flower.txt");
8 File newFile = new File("D:\\Project\\flowerbrackets.txt");
9 if(oldFile.renameTo(newFile))
10 {
11 System.out.println("Rename successful");
12 }
13 else
14 {
15 System.out.println("Rename failed");
16 }
17 }
18}