我现在已经阅读了许多有关 Java somePath.resolve( someOtherPath )
使用的文章,但我找不到准确的定义以及有用的示例,确切地说 “解析”路径的意思。每个人似乎都假设你知道。
有人可以非循环地定义它吗?或者给我指出一个(非循环)解释器?
最佳答案
这个问题的答案在 documentation 中定义。 ,它很好地表明了该方法的作用。
Converts a given path string to a Path and resolves it against this Path in exactly the manner specified by the resolve method. For example, suppose that the name separator is "/" and a path represents "foo/bar", then invoking this method with the path string "gus" will result in the Path "foo/bar/gus".
换句话说,如果路径C:/Program Files/Foo/
是当前Path
并且Bar
存在于中Foo
,您可以执行以下操作:
Path parent = Paths.get("C:", "Program Files", "Foo");
Path child = parent.resolve("Bar");
关于java - "resolve"路径到底意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67187401/