Page 1 of 1

About Question enthuware.ocpjp.v7.2.1605 :

Posted: Sat Jan 09, 2016 4:16 pm
by sir_Anduin@yahoo.de
Hi,

I cant fugure out what resolving means.
could you make an example?

I tried some path combination like in the question, but i dont understand what the method is doing. (besides: 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)

Thanks

Re: About Question enthuware.ocpjp.v7.2.1605 :

Posted: Sat Jan 09, 2016 8:50 pm
by admin
To understand resolve, it would be easier if you understand relativize first because resolve is the opposite of relativize. With respect to paths, relativise basically means, reaching the target (i.e. argument) directory from the source (i.e. this), directory. For example, lets say you are on a command/shell prompt and you are currently in /user/a/b/c. Now, how will you go to /user/a/b/c/d?
You will just do "cd d", right? That means relative to "/user/a/b/c", the path "/user/a/b/c/d" is just "d".

Therefore, "/user/a/b/c".relativize("/user/a/b/c/d") should give you just "d".

Resolve is opposite of the above process. "/user/a/b/c".resolve("d") will give you "/user/a/b/c/d".

HTH,
Paul.

Re: About Question enthuware.ocpjp.v7.2.1605 :

Posted: Tue Jul 18, 2023 5:51 pm
by xavier_devm
explanation for option 4 says
When the argument to resolve starts with the root (such as c: or, on *nix, a /), the result is same as the argument
but the general explanation says
Where the given path has a root component then resolution is highly implementation dependent and therefore unspecified.
which is contradictory. I think the explanation for option 4 should be
When the argument to resolve is an absolute path, the result is same as the argument
Reference: https://stackoverflow.com/questions/188 ... ath-method

Personally, I can't see a possible scenario for a path with a root component not being an absolute path, by the way

Re: About Question enthuware.ocpjp.v7.2.1605 :

Posted: Wed Jul 19, 2023 12:33 am
by admin
This is taken directly from the JavaDoc API description for resolve.


I don't think it is contradictory. There are two scenarios -
1. "If the other parameter is an absolute path then this method trivially returns other. "
This means the "other" path starts with a c: or / (or whatever makes the path absolute on that system).

2. " Where the given path has a root component then resolution is highly implementation dependent and therefore unspecified."
I believe that this means the "other" path contains a root component for example /a1/c:/a2. In this case the result is "highly implementation dependent and therefore unspecified"

HTH,
Paul.