Last active
December 29, 2016 17:56
-
-
Save masayuki038/b8c913aad18df7e26a2af9e3d60c7853 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.wrap_trap.sample; | |
import java.io.*; | |
import java.nio.file.Files; | |
public class Main { | |
public static void main(String[] args) throws IOException { | |
if(args.length != 2) { | |
System.err.println("remove-hardlink-test [source] [hardlink]"); | |
System.exit(-1); | |
} | |
File source = new File(args[0]); | |
File hardLink = new File(args[1]); | |
try(FileWriter fw = new FileWriter(source)) { | |
fw.write("Hello World"); | |
} | |
Files.createLink(hardLink.toPath(), source.toPath()); | |
try(BufferedReader fr = new BufferedReader(new FileReader(source))) { | |
System.out.println("read: " + fr.readLine()); | |
System.out.println("hardLink#delete: " + hardLink.delete()); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
masayuki@MASAYUKI-PC:/tmp$ /usr/lib/jvm/java-8-openjdk-amd64/bin/java -cp /mnt/d/development/repository/git/remove-hardlink-test/out/production/remove-hardlink-test net.wrap_trap.sample.Main hoge.txt hoge_link.txt | |
read: Hello World | |
hardLink#delete: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
masayuki@masayuki-PC /cygdrive/d/development/repository/git/remove-hardlink-test/out/production/remove-hardlink-test | |
$ java -cp . net.wrap_trap.sample.Main hoge.txt hoge_link.txt | |
read: Hello World | |
hardLink#delete: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[masayuki@c793019b8fb5 work]$ java -cp . net.wrap_trap.sample.Main hoge.txt hoge_link.txt | |
read: Hello World | |
hardLink#delete: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\development\repository\git\remove-hardlink-test\out\production\remove-hardlink-test> java -cp . net.wrap_trap.sample.Main hoge.txt hoge_link.txt | |
read: Hello World | |
hardLink#delete: false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment