Java Files copy symbolic links

Description

Java Files copy symbolic links

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/css/users.txt");
      Path newLinkedFile = FileSystems.getDefault().getPath("C:/home/java/users2.txt");
      try {//from w  w w .  jav a 2  s .c o  m
         Files.copy(originalLinkedFile, newLinkedFile);
         System.out.println("Symbolic link file copied successfully!");
      } catch (IOException e) {
         System.out.println("IO Exception.");
      }

   }

}



PreviousNext

Related