java 修改文件名

    // 修改文件名
    
    public static boolean modifyFileName(String serverPath, String oldFileName,
            String newLoginNo) {
        String oldPath = serverPath + "/" + oldFileName;
        String newPath = serverPath + "/" + newLoginNo + "-"
                + oldFileName.substring(oldFileName.indexOf('-') + 1);
        File oldFile = new File(oldPath);
        File newFile = new File(newPath);
        if (oldFile.renameTo(newFile)) {
            return true;
        } else {
            return false;
        }
    }

 

posted on 2014-10-23 16:23  hellofking  阅读(301)  评论(0编辑  收藏  举报

导航