0

I am trying to get Java 8 certification i already have Java 6 a long time ago and Java 7 is my weak point because i havent work with it i am a little confuse.

What is a symbolic Link??

According to wikipedia.

In computing, a symbolic link (also symlink or soft link) is a term for any file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution.

My questions are.

How Java recognize a symbolic link i mean when this would print true?

final Path path = ...
System.out.println(Files.isSymbolicLink(path));

Perhaps this is a silly question but i really want to know!!

chiperortiz
  • 4,751
  • 9
  • 45
  • 79
  • 1
    In unix, it would be a "file" create with `ln -s ....`.and in Windows with `mklink ...`. The OS knows how to distinguish them and `nio` certainly use the JNI for those request. JNI is the Java Native Interface that allows you to implement a java interface in another language like C by the OS. – AxelH May 24 '18 at 13:53

1 Answers1

2

On my ubuntu, I have create two files in /tmp/

echo "Hello world" > file.txt
ln -s file.txt link.txt

If I check for both file .

Files.isSymbolicLink(Paths.get("/tmp/file.txt")) //false
Files.isSymbolicLink(Paths.get("/tmp/link.txt")) //true

Same would works on Windows with a file and a link made with mklink.

AxelH
  • 14,325
  • 2
  • 25
  • 55