Java examples for File Path IO:Directory Copy
Copying a directory using Files.copy() method
import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; public class Main { public static void main(String[] args) { Path originalDirectory = FileSystems.getDefault().getPath("C:/home/docs"); Path newDirectory = FileSystems.getDefault().getPath("C:/home/tmp"); try {/* w ww . j ava 2s . com*/ Files.copy(originalDirectory, newDirectory); System.out.println("Directory copied successfully!"); } catch (IOException e) { e.printStackTrace(); } } }