xdevel2000
xdevel2000

Reputation: 21364

NIO.2 Path.toRealPath problem

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.

Upvotes: 0

Views: 1290

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533500

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?

Upvotes: 4

Related Questions