0

I have the following code where ac.lnk point to c:\t.txt

Path p = Paths.get("C:\\Users\\joshua\\Desktop\\ac.lnk");
Path _rp = p.toRealPath();

but _rp doesn't contain the path with he symbolic link expanded to c:\t.txt

I read from the doc http://download.java.net/jdk7/docs/api/java/nio/file/Path.html#toRealPath that only if I use as argument LinkOption.NOFOLLOW_LINKS then realPath does not resolve symbolic links.

Thanks.

xdevel2000
  • 20,780
  • 41
  • 129
  • 196

1 Answers1

4

ac.lnk is an executable file known as a shortcut, not a symbolic link. Windows Explorer can read the path in the file and pretend its a link.

Perhaps what you are looking for a Shortcut reader.

Windows shortcut (.lnk) parser in Java?

How do you create (and read) windows shortcut(.lnk file) in Java?

Community
  • 1
  • 1
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130