Android File Rename renameFile(File file, File newFile, boolean isDeleteExistDestFile)

Here you can find the source of renameFile(File file, File newFile, boolean isDeleteExistDestFile)

Description

rename File

Parameter

Parameter Description
file a parameter
newFile Must contain full path.
isDeleteExistDestFile a parameter

Declaration

public static boolean renameFile(File file, File newFile,
        boolean isDeleteExistDestFile) 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {
    /**//from w ww. j av  a  2 s.  com
     * 
     * @param file
     * @param newFile Must contain full path.
     * @param isDeleteExistDestFile
     * @return
     */
    public static boolean renameFile(File file, File newFile,
            boolean isDeleteExistDestFile) {
        if (newFile.exists()) {
            if (isDeleteExistDestFile) {
                newFile.delete();
            }
        }
        return file.renameTo(newFile);
    }
}

Related

  1. renameFile(String origPath, String destPath)
  2. renameFile(String source, String dest)
  3. renameFile(String strSrc, String strDest)
  4. renameFiles(File file, String filterRegex, String replaceRegex, String replacement)
  5. renameFiles(File file, String regex, String replacement)