Java Rename File rename(String strFileName, String strRenameToName)

Here you can find the source of rename(String strFileName, String strRenameToName)

Description

rename

License

Open Source License

Parameter

Parameter Description
strFileName a parameter
strRenameToName a parameter

Return

boolean

Declaration

public static boolean rename(String strFileName, String strRenameToName) 

Method Source Code


//package com.java2s;
import java.io.File;

public class Main {

    public static boolean rename(String strFileName, String strRenameToName) {
        File f = new File(strFileName);
        if (f.exists()) {
            if (strRenameToName.indexOf('/') < 0) {
                strRenameToName = (f.getParent() + "/" + strRenameToName).replace("//", "/");
            }/*from w  ww .j a v a  2s  . c  om*/
            return f.renameTo(new File(strRenameToName));
        }
        return false;
    }
}

Related

  1. reName(String oldName, String newName)
  2. rename(String platformLibPath, String newPath)
  3. reName(String s, String s1)
  4. rename(String srcFilename, String destFilename)
  5. rename(String srcPath, String destPath)
  6. rename(String was_name, String new_name)
  7. rename_file_to_file(String n1, String n2)
  8. renameBackup(File backupFile)
  9. renameCanDelete()