Java Rename File renameFile(String sourcePath, String targetPath)

Here you can find the source of renameFile(String sourcePath, String targetPath)

Description

rename File

License

Apache License

Declaration

public static Boolean renameFile(String sourcePath, String targetPath) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.io.IOException;

public class Main {
    public static Boolean renameFile(String sourcePath, String targetPath) throws IOException {
        File oldFile = new File(sourcePath);
        File newFile = new File(targetPath);
        if (oldFile.isFile()) {
            oldFile.renameTo(newFile);/*from w w w . j a  v  a2s  .  co  m*/
            return true;
        } else {
            return false;
        }
    }
}

Related

  1. renameDirectory(String newDir, String oldDir)
  2. renameExcludedFiles(File existingBinaryFolder, Collection excludedBids)
  3. renameExistingWithRetries(final File fromFile, final File toFile)
  4. renameFile(File src, File dest)
  5. renameFile(String source, String dest)
  6. renameFile(String src_pathname, String dest_pathname)
  7. renameFileFromChinese(File file)
  8. renameFileHard(File srcFile, File destFile)
  9. renameFileIfExists(File f)