Java Rename File renameOldFile(final String fileName)

Here you can find the source of renameOldFile(final String fileName)

Description

rename Old File

License

Open Source License

Declaration

public static void renameOldFile(final String fileName) 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {
    public static void renameOldFile(final String fileName) {
        final File file = new File(fileName);
        if (file.exists()) {
            final File oldFile = new File(fileName + ".old");
            if (oldFile.exists()) {
                oldFile.delete();/*www .  j  a v  a2  s. c o m*/
            }

            file.renameTo(oldFile);
        }
    }
}

Related

  1. renameFileOnWindows(File oldFile, File newFile)
  2. renameFiles(File fileDirectory, String regex, String replacement)
  3. renameFiles(String rootDir, String sourcePostfix, String destPostfix)
  4. renameFolder(String destinationFolderPath, String zipFileName, String prefix)
  5. renameLocal(String oldPath, String newPath)
  6. renameOverwrite(String oldname, String newname)
  7. renameSuffix(File f, String suffix)
  8. renameTempDMLScript(String dmlScriptFile)
  9. renameTo(File currentFile, String newName)