What is the output of the following code?
Path path1 = Paths.get("/pin/./bin/abc/../code/../Hello.java");
System.out.println(path1.normalize());
e
Method normalize()
removes the redundancies like " ." (current directory) and " .." (parent directory) from a path.
Because " ." denotes the current directory, it's simply removed by normalize()
.
" .." is only removed if it is preceded by a non-" .." name.
In the following example, no redundancies are removed:
System.out.println(Paths.get("../../OCPJava7/8.1.txt").normalize());