集册 Java实例教程 创建指向目录的符号链接

创建指向目录的符号链接

欢马劈雪     最近更新时间:2020-01-02 10:19:05

403
创建指向目录的符号链接

import java.io.IOException;

import java.nio.file.Files;

import java.nio.file.Path;// from 时 代 J a v a - N o w J a v a . c o m

import java.nio.file.Paths;


public class Main {

  public static void main(String[] args) throws Exception {

    try {

      Path targetFile = Paths.get("C:/home/docs");

      Path linkFile = Paths.get("C:/home/tmp");

      Files.createSymbolicLink(linkFile, targetFile);

    } catch (IOException ex) {

      ex.printStackTrace();

    }


  }


}//来自 时 代 J a v a 公 众 号