Java tutorial
import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void main(String[] args) throws Exception { Path p2 = Paths.get("test2.txt"); // Follow link for p2, if it is a symbolic link Path p2RealPath = p2.toRealPath(); System.out.println("p2RealPath:" + p2RealPath); Path p3 = Paths.get("test3.txt"); // Do not follow link for p3, if it is a symbolic link Path p3RealPath = p3.toRealPath(LinkOption.NOFOLLOW_LINKS); System.out.println("p3RealPath:" + p3RealPath); } }