Java examples for File Path IO:Symbolic Link
Create a hard link
import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; /**/*from w w w .jav a 2 s. c om*/ */ public class HardLink { /* Create a hard link: Windows: mklink /H newlinkfolder targetfolder linux: ln targetfolder newlinkfolder */ public static void main(String[] args) { Path link = FileSystems.getDefault().getPath("D:/intro/new"); Path target = FileSystems.getDefault().getPath("C:/Users"); try { //Files.createLink Files.createLink(link, target); } catch (IOException | UnsupportedOperationException e) { e.printStackTrace(); if (e instanceof UnsupportedOperationException) { System.out.println("UnsupportOp!"); } } } }