创建符号链接
import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files;//来 自 NowJava.com - 时 代 Java import java.nio.file.Path; public class Main { public static void main(String[] args) { Path link = FileSystems.getDefault().getPath("test"); Path target = FileSystems.getDefault().getPath("C:/folder1/photos", "test.jpg"); try { Files.createSymbolicLink(link, target); } catch (IOException | UnsupportedOperationException | SecurityException e) { if (e instanceof SecurityException) {/* 来 自 nowjava.com*/ System.err.println("Permission denied!"); } if (e instanceof UnsupportedOperationException) { System.err.println("An unsupported operation was detected!");