src/org/nutz/lang/Files.java
public static boolean rename(File src, String newName) {
        if (src == null || newName == null)
            return false;
        if (src.exists()) {
            File newFile = new File(src.getParent() + "/" + newName);
            if (newFile.exists())
                return false;
            Files.makeDir(newFile.getParentFile());
            return src.renameTo(newFile);
        }
        return false;
    }
public static boolean rename(File src, String newName) {
        if (src == null || newName == null)
            return false;
        if (src.exists()) {
            File newFile = new File(src.getParent() + "/" + newName);
            if (newFile.exists())
                return false;
            Files.makeDir(newFile.getParentFile());
            return src.renameTo(newFile);
        }
        return false;
    }
public static boolean rename ( File src , String newName ) { if ( src == null || newName == null ) return false ; if ( src . exists ( ) ) { File newFile = new File ( src . getParent ( ) + "/" + newName ) ; if ( newFile . exists ( ) ) return false ; Files . makeDir ( newFile . getParentFile ( ) ) ; return src . renameTo ( newFile ) ; } return false ; }
将文件改名

@param src
文件
@param newName
新名称
@return 改名是否成功
将文件改名