String path = "";
String oldname = "";
String newanme = "";
File oldfile = new File(path+"/"+oldname+".jpg");
File newfile = new File(path+"/"+newname+".jpg");
oldfile.renameTo(newfile);
System.out.println(newfile.getName());
完成的是替换,如果重命名后打出oldfile的名字,依然不变。