Reputation: 15
For the following code, the aPath turns out to be D:\ OCPJP7\ NIO2\ src\SubPath.java. Why is the programs element gone?
Path aPath = Paths.get(" D:\\ OCPJP7\\ programs\\..\\ NIO2\\ src\\.\\ SubPath.java");
aPath = aPath.normalize();
Upvotes: 1
Views: 1154
Reputation: 48404
Because the normalization replaced the ..
programs
' parent directory.
So you have NIO2
as a sub-folder of OCPJP7
.
Similarly, .
goes away as it's redundant (indicates current directory within context).
Upvotes: 1
Reputation: 31269
Because the programs element is followed by \\..\\
which means "to go up one directory level". This sequence removes the \\programs\\
part from your path.
Upvotes: 1