重命名文件或目录
import java.io.File; /** 来自 nowjava.com - 时 代 Java**/ public class Main { public void m() { // File (or directory) with old name File file = new File("oldname"); // File (or directory) with new name File file2 = new File("newname"); // Rename file (or directory) boolean success = file.renameTo(file2); if (!success) { // File was not successfully renamed }/**来自 时 代 J a v a 公 众 号**/ } }