Java File Rename renameFile(String oldPath, String newPath)

Here you can find the source of renameFile(String oldPath, String newPath)

Description

rename File

License

Apache License

Declaration

public static void renameFile(String oldPath, String newPath) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    public static void renameFile(String oldPath, String newPath) {
        try {/*from  w  w w  .  j  av  a2  s . c om*/
            File dest = null;
            if (!oldPath.equals(newPath)) {
                File file = new File(oldPath);
                dest = new File(newPath);
                file.renameTo(dest);
            }
        } catch (Exception e) {
        }
    }
}

Related

  1. renameFile(String oldFileName, String newFileName)
  2. renameFile(String oldname, String newname)
  3. renameFile(String oldname, String newname)
  4. renameFile(String oldname, String newone)
  5. renameFile(String oldPath, String newName)
  6. renameFile(String oldPath, String newPath, boolean overwrite)
  7. renameFile(String origPath, String destPath)
  8. renameFile(String path, String newPath)