Java Rename File rename(String from, String to)

Here you can find the source of rename(String from, String to)

Description

rename

License

Open Source License

Parameter

Parameter Description
from a parameter
to a parameter

Declaration

public static boolean rename(String from, String to) 

Method Source Code


//package com.java2s;
import java.io.File;

public class Main {
    /**/*  ww w . ja v  a2s. c  o m*/
     * @param from
     * @param to
     * @return
     */
    public static boolean rename(String from, String to) {
        File fFrom = new File(from);
        File fTo = new File(to);

        if (!fFrom.exists()) {
            return false;
        } else {
            return fFrom.renameTo(fTo);
        }
    }
}

Related

  1. rename(File src, String name)
  2. rename(File srcFile, String newName)
  3. rename(final String src, final String dst)
  4. rename(String existingFile, String newFilename)
  5. rename(String fileName, String distFile)
  6. rename(String oldFile, String newFile)
  7. rename(String oldName, String newName)
  8. reName(String oldName, String newName)
  9. rename(String platformLibPath, String newPath)