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
About Question enthuware.ocpjp.v7.2.1605 :
Moderator: admin
-
- Posts: 62
- Joined: Fri Aug 07, 2015 2:16 pm
- Contact:
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1605 :
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.
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 1
- Joined: Tue Jul 04, 2023 10:51 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1605 :
explanation for option 4 says
Personally, I can't see a possible scenario for a path with a root component not being an absolute path, by the way
but the general explanation saysWhen the argument to resolve starts with the root (such as c: or, on *nix, a /), the result is same as the argument
which is contradictory. I think the explanation for option 4 should beWhere the given path has a root component then resolution is highly implementation dependent and therefore unspecified.
Reference: https://stackoverflow.com/questions/188 ... ath-methodWhen the argument to resolve is an absolute path, the result is same as the argument
Personally, I can't see a possible scenario for a path with a root component not being an absolute path, by the way
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1605 :
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.
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.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 228 guests