Given a directory tree at the root of the C: drive and the fact that no other files exist:
dir x - | ..........| - dir y ..........| - file a
and these two paths:
Path one = Paths.get("c:/x"); Path two = Paths.get("c:/x/y/a");
Which of the following statements prints out: y/a ?
A is correct because it prints the path to get to two from one.
B is incorrect because it prints out ../.. which is the path to navigate to one from two.
This is the reverse of what we want.
C, D, and E are incorrect because it does not make sense to call resolve with absolute paths.
They might print out c:/x/c:/x/y/a, c:/x/y/a/c:/x, and c:/x/y/a/c:/x/y/a, respectively.
F is incorrect because of the above.
Note that the directory structure provided is redundant.
Neither relativize()
nor resolve()
requires either path to actually exist.