i want to create a hardlink from a file "C:\xxx.log" to "C:\mklink\xxx.log" . In cmd it works of course, but i want to write a software for this usecase.
- So have to locate the existing file
- Then make a hardlink
- Then delete the old file
I started to implement but, i just know how to create a file. On google i found nothing about mklink \H for Java.
public void createFile() {
boolean flag = false;
// create File object
File stockFile = new File("c://mklink/test.txt");
try {
flag = stockFile.createNewFile();
} catch (IOException ioe) {
System.out.println("Error while Creating File in Java" + ioe);
}
System.out.println("stock file" + stockFile.getPath() + " created ");
}