I am trying to get the real path from a symbolic link but no success.
Operating system: Mac Java version: Java 9
I am seeing the documentation from: https://docs.oracle.com/javase/tutorial/essential/io/links.html
I have following folder structure on my computer...
I have kept real file is in
/Users/Name/Desktop/realfile.txt
I have created a symbolic link of realfile.txt as realfile_alias and kept it in
/Users/Name/WorkSpace/Test/data/realfile_alias
I am running java program from
/Users/Name/WorkSpace/Test/src folder.
My source code:
String sPath = "data/realfile_alias" // this is relative path. I have kept the symbolic link in data folder.
Path path = Paths.get(sPath);
boolean isSymbolic = Files.isSymbolicLink(path);
// it returns true
Path realPath = Files.readSymbolicLink(path);
realPath is just returning /Users/Name/WorkSpace/Test/data/realfile_alias But I expect it to be /Users/Name/Desktop/realfile.txt
How can I get the real path from symbolic path?