Java examples for File Path IO:File Copy
Perform the copy operation with 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 originalLinkedFile = FileSystems.getDefault().getPath( "C:/home/music/users.txt"); Path newLinkedFile = FileSystems.getDefault().getPath( "C:/home/music/users2.txt"); try {/*from ww w . j a v a 2 s. c om*/ Files.copy(originalLinkedFile, newLinkedFile); System.out.println("Symbolic link file copied successfully!"); } catch (IOException e) { System.out.println("IO Exception."); } } }