Path of "." and ""
Wang Weijun
weijun.wang at oracle.com
Mon Dec 8 09:37:53 UTC 2014
Path p1 = Paths.get(".");
Path p2 = Paths.get("./s");
Then p2.startsWith(p1) is true.
If I normalize them, p1 becomes "", p2 becomes "s", and p2.startsWith(p1) is false.
I know it's because after normalizing, p1 has an element which is "", and p2 has an element which is "s", therefore one array does not starts with the other. Maybe p1 should be normalized to no element at all?
And what is the best way to check if one path is inside another? I do not want to call toAbsolutePath().
Thanks
Max
More information about the nio-dev
mailing list