• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79041
375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic