import java.io.File;
public class FileRename {
public static void main(String[] args) {
File oldName = new File("copyfile");
File newName = new File("cpyFile2");
if (oldName.renameTo(newName)){
System.out.println("文件已重命名!");
}else {
System.out.println("Error!!!!!");
}
}
}
![img_2be76ce5d7cb9096876c6e11a7af24aa.png](https://yqfile.alicdn.com/img_2be76ce5d7cb9096876c6e11a7af24aa.png?x-oss-process=image/resize,w_1400/format,webp)