resolve
Path resolve(Path other)
Resolve the given path against this path.
If the other parameter is an absolute path then this method trivially
returns other. If other is an empty path then this method trivially
returns this path. Otherwise this method considers this path to be a
directory and resolves the given path against this path. In the
simplest case,the given path does not have a root component,in which
case this method joins the given path to this path and returns a
resulting path that ends with the given path. Where the given path has
a root component then resolution is highly implementation dependent
and therefore unspecified.
(强调我的)
这里有一点矛盾,首先他们说:
然后他们说:
>如果给定路径具有根组件,则解决方案高度依赖于实现,因此未指定.
绝对路径是否必须包含根组件才能成为这样的组件?
提前致谢.
解决方法
如果我们看一下source code for UnixPath,我们确实看到,如果它是一个绝对路径,那么它将返回一个根组件,它将只返回一个根组件.
但是,并不要求以这种方式实施.理论上至少,getRoot()可以返回一些东西,而isAbsolute()则返回false.在此,结果是不确定的.或者,将其放在真值图表格中:
Result of resolve() when: getRoot()==null getRoot()!=null isAbsolute()==true defined defined isAbsolute()==false defined undefined