首页 > 其他分享 >file 重命名

file 重命名

时间:2022-11-30 19:24:17浏览次数:43  
标签:重命名 newPath file String demo targetFolderPath public

public class FileUtils {
 //重命名文件
    public static void reNameFile(String oldPath, String newPath) {
       boolean result = new File(oldPath).renameTo(new File(newPath));
       System.out.println("重命名的结果:" + result);
    }


    //测试方法
    public static void main(String[] args) {
        String sourceFolderPath = "D:/demo/aaa-20220307.txt";
        String targetFolderPath = "D:/demo/aaa.txt";
        reNameFile(sourceFolderPath, targetFolderPath);
    }
}

 

标签:重命名,newPath,file,String,demo,targetFolderPath,public
From: https://www.cnblogs.com/JYB2021/p/16939492.html

相关文章