Java examples for File Path IO:Directory Move
options for Moving Files and Directories are listed as follows.
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) throws Exception { Path movefrom = FileSystems.getDefault().getPath( "C:/folder1/test.jpg"); Path moveto = FileSystems.getDefault().getPath( "C:/folder1/photos/test.jpg"); try {/*from w w w . j av a2 s. co m*/ Files.move(movefrom, moveto, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { System.err.println(e); } } }