Java examples for File Path IO:File Path
Create Path from path string
import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; /**//from w ww . ja va2 s.c o m */ 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!"); } } } }