Here you can find the source of rename(Path origin, Path destination)
Parameter | Description |
---|---|
origin | origin path to be renamed. |
destination | The new destination path for the named path |
Parameter | Description |
---|---|
IOException | if something goes wrong. |
public static void rename(Path origin, Path destination) throws IOException
//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); } }