• Post Reply Bookmark Topic Watch Topic
  • New Topic

resolve(Path other) method in java.nio.file.path class  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day!

As we can see in API documentation, the aim of the method (from the post subject )is to resolve the given path against this path.

2 particular cases:
A. If the given path is absolute
If the other parameter is an absolute path then this method trivially returns other.
B. If the given path is not empty and not absolute
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.

But can somebody explain results of running the following code:
----printed text--------
isAbsolute method return - \home\joe : false
resolve method return - \home\joe
toAbsolutePath method return - C:\home\joe
---------------------------
Why does resolve method returns original path, like if the 'path' argument is absolute? at the same time isAbsolute method invoked on 'path' returns false.
Thank you!
 
Dmitriy Deyneko
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, the question is closed.

In Windows runtime environment \home\joe\ path is not absolute but has root component. The root component is \.
As API Docs said about Path.resolve(path) method =
Where the given path has a root component then resolution is highly implementation dependent and therefore unspecified

Therefore, we can't expect some specific and defined output from Path.resolve method.

I've make a mistake in the theme of topic - of course Path is an Interface.
 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!