Files.move(Path source, Path target, CopyOption ... options) has the following syntax.
public static Path move(Path source, Path target, CopyOption ... options) throws IOException
In the following code shows how to use Files.move(Path source, Path target, CopyOption ... options) method.
/*from w w w . j av a 2 s. c o m*/ import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; public class Main { public static void main(String[] args) { Path movefrom = FileSystems.getDefault().getPath("C:/tutorial/Swing_2.jpg"); Path target = FileSystems.getDefault().getPath("C:/tutorial/photos/Swing_2.jpg"); Path target_dir = FileSystems.getDefault().getPath("C:/tutorial/photos"); //method 1 try { Files.move(movefrom, target, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { System.err.println(e); } } }