Here you can find the source of move(Path source, Path destination)
Parameter | Description |
---|---|
source | The source path. |
destination | The destination path. |
Parameter | Description |
---|---|
IOException | If the file could not be moved. |
public static void move(Path source, Path destination) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.file.AtomicMoveNotSupportedException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; public class Main { /**/* ww w . j av a2s. c om*/ * Attempts to move the file represented by the specified {@link Path} to the specified destination atomically, * resorting to moving it non-atomically if atomic operations are not supported by the source or destination file * system. * * @param source The source path. * @param destination The destination path. * @throws IOException If the file could not be moved. */ public static void move(Path source, Path destination) throws IOException { try { Files.move(source, destination, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE); } catch (AtomicMoveNotSupportedException e) { Files.move(source, destination, StandardCopyOption.REPLACE_EXISTING); } } }