Java Rename File renameLocal(String oldPath, String newPath)

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

Description

rename Local

License

Open Source License

Declaration

public static boolean renameLocal(String oldPath, String newPath) 

Method Source Code

//package com.java2s;
/**//from  w ww. j  av a 2 s .c  om
Mybox version 0.1.0
https://github.com/mybox/mybox
    
Copyright (C) 2011  Jono Finger (jono@foodnotblogs.com)
    
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
    
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License along
with this program; if not it can be found here:
http://www.gnu.org/licenses/gpl-2.0.html
 */

import java.io.*;

public class Main {
    public static boolean renameLocal(String oldPath, String newPath) {
        System.out.println("Renaming local item " + oldPath + " to " + newPath);

        File oldFile = new File(oldPath);
        File newFile = new File(newPath);

        return (oldFile.renameTo(newFile));

        //      System.out.println("Error durring rename");
    }
}

Related

  1. renameFileIfExists(File f)
  2. renameFileOnWindows(File oldFile, File newFile)
  3. renameFiles(File fileDirectory, String regex, String replacement)
  4. renameFiles(String rootDir, String sourcePostfix, String destPostfix)
  5. renameFolder(String destinationFolderPath, String zipFileName, String prefix)
  6. renameOldFile(final String fileName)
  7. renameOverwrite(String oldname, String newname)
  8. renameSuffix(File f, String suffix)
  9. renameTempDMLScript(String dmlScriptFile)