Java File Rename renameFile(String filePath, String descFilePath)

Here you can find the source of renameFile(String filePath, String descFilePath)

Description

rename file

License

Open Source License

Declaration

public static boolean renameFile(String filePath, String descFilePath) 

Method Source Code

//package com.java2s;
/*/* w  ww  . j  a v a 2 s  .co  m*/
* Copyright 2016 Yonyou Corporation Ltd. All Rights Reserved.
*
* This software is published under the terms of the Yonyou Software
* License version 1.0, a copy of which has been included with this
* distribution in the LICENSE.txt file.
*
* @Project Name : cmol.common.function
*
* @File name : IOUtils.java
*
* @Author : zhangxianchao
*
* @Date : 2016?2?29?
*
----------------------------------------------------------------------------------
*     Date       Who       Version     Comments
* 1. 2016?2?29?    zhangxianchao    1.0
*
*
*
*
----------------------------------------------------------------------------------
*/

import java.io.File;

public class Main {
    /**
     * rename file
     */
    public static boolean renameFile(String filePath, String descFilePath) {
        File file = new File(filePath);
        if (!file.exists()) {
            return false;
        }
        File descFile = new File(descFilePath);
        if (descFile.exists()) {
            return false;
        }
        return file.renameTo(descFile);
    }
}

Related

  1. renameFile(final String oldName, final String newName)
  2. renameFile(String currentPath, String newPath)
  3. renameFile(String file, String toFile)
  4. renameFile(String fileFrom, String fileTo)
  5. renameFile(String fileName, String destFilename)
  6. renameFile(String from, String to, String baksuffix)
  7. renameFile(String fromFilename, String toFilename)
  8. renameFile(String newName, String oldName)
  9. renameFile(String oldFile, String newName)