Java Files create symbolic link to directory

Description

Java Files create symbolic link to directory

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
   public static void main(String[] args) throws Exception {
      try {//from   ww  w.  j  a va 2 s.  c o m
         Path targetFile = Paths.get("C:/home/docs");
         Path linkFile = Paths.get("C:/home/tmp");
         Files.createSymbolicLink(linkFile, targetFile);
      } catch (IOException ex) {
         ex.printStackTrace();
      }
   }
}



PreviousNext

Related