Java Path File Name nio rename(Path origin, Path destination)

Here you can find the source of rename(Path origin, Path destination)

Description

Renames the origin path denoted by the new destination path.

License

Open Source License

Parameter

Parameter Description
origin origin path to be renamed.
destination The new destination path for the named path

Exception

Parameter Description
IOException if something goes wrong.

Declaration

public static void rename(Path origin, Path destination) throws IOException 

Method Source Code


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

import java.nio.file.*;

public class Main {
    /**/* w  ww .  j  a v  a  2  s  . co  m*/
     * Renames the origin path denoted by the new destination path.
     *
     * @param origin      origin path to be renamed.
     * @param destination The new destination path for the named path
     * @throws IOException if something goes wrong.
     */
    public static void rename(Path origin, Path destination) throws IOException {
        //        origin.toFile().renameTo(destination.toFile());
        Files.move(origin, destination, StandardCopyOption.REPLACE_EXISTING);
    }
}

Related

  1. listDocTypeName(Path path)
  2. makeUnique(Path basePath, String baseName)
  3. pathToPackageName(Path path)
  4. readFileFromPath(String filename)
  5. relativizePath(Path relativeTo, String filename)
  6. renameFile(Path filePath, String postfix)
  7. renameLogFile(Path original)
  8. saveFileFromByteArray(String filename, String pathDirectory, byte[] data)
  9. saveNamesToFile(Map namesMap, Path namesFile)