CreateLink方法创建到现有文件的硬链接
import java.io.IOException; import java.nio.file.Files; /** from * n o w j a v a . c o m - 时代Java **/ import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void main(String[] args) throws Exception { try { Path targetFile = Paths.get("C:/home/docs/users.txt"); Path linkFile = Paths.get("C:/home/music/users.txt"); Files.createLink(linkFile, targetFile);