Android Utililty Methods File Rename

List of utility methods to do File Rename

Description

The list of methods to do File Rename are organized into topic(s).

Method

booleanmark(String pathName, String tag)
mark
if (pathName != null & tag != null) {
    File arch = new File(pathName);
    File newArch = new File(pathName + tag);
    arch.renameTo(newArch);
    return true;
return false;
Filerename(File file1, File file2)
Trys to rename file1 to file2.
Check.arg().validFile(file1);
Check.arg().notNull(file2);
if (file2.exists() && !file1.equals(file2))
    throw new IllegalArgumentException("file2 = " + file2.getPath()
            + " already exists and is not equal to file1 = "
            + file1.getPath());
boolean renamed = file1.renameTo(file2);
if (!renamed)
...
voidrename(File fromFile, File toFile)
Renames fromFile to toFile.
boolean success = false;
Random random = null;
for (int i = 0; i < 3; i++) {
    if (i > 0) {
        try {
            random = (random != null) ? random : new Random();
            Thread.sleep(100 + random.nextInt(128));
        } catch (InterruptedException ex) {
...
Filerename(String from, String to)
rename
File file = new File(from);
file.renameTo(new File(to));
return file;
booleanrename(String oldName, String newName)
Renames a file or directory.
File fold = new File(oldName);
File fnew = new File(newName);
return fold.renameTo(fnew);
booleanrenameAs(String pathDir, String name, String wishName)
rename As
if (pathDir != null & name != null & wishName != null) {
    File arch = new File(pathDir + "/" + name);
    File newArch = new File(pathDir + "/" + wishName);
    arch.renameTo(newArch);
    return true;
return false;
voidrenameFile(File source, File dest)
rename File
source.renameTo(dest);
voidrenameFile(String origPath, String destPath)
Convenience function to rename (move) a file.
File orig = new File(origPath);
File dest = new File(destPath);
if (SysUtil.getOperatingSystem() == SysUtil.OS.WINDOWS
        && dest.exists())
    dest.delete();
if (!orig.renameTo(dest))
    throw new IOException(String.format(
            "Unable to rename file from '%1$s' to '%2$s'",
...
voidrenameFile(String source, String dest)
rename File
File file = new File(source);
file.renameTo(new File(dest));
booleanrenameFile(String strSrc, String strDest)
Rename file from src to des, override if des exist
File flSrc = new File(strSrc);
File flDest = new File(strDest);
if (flSrc.getAbsolutePath().equals(flDest.getAbsolutePath()))
    return true;
if (flDest.exists())
    flDest.delete();
return flSrc.renameTo(flDest);