Creating a symbolic link to a directory - Java File Path IO

Java examples for File Path IO:Symbolic Link

Description

Creating a symbolic link to a directory

Demo Code

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  w  w w .  ja va  2s.  c om
      Path targetFile = Paths.get("C:/home/docs");
      Path linkFile = Paths.get("C:/home/tmp");
      Files.createSymbolicLink(linkFile, targetFile);
    } catch (IOException ex) {
      ex.printStackTrace();
    }

  }

}

Related Tutorials