Given:
String originalPath = “data\\projects\\a-project\\..\\..\\another-project”;
Path path = Paths.get(originalPath);
System.out.print(path.normalize());
What is the result?
Given:
String originalPath = “data\\projects\\a-project\\..\\..\\another-project”;
Path path = Paths.get(originalPath);
System.out.print(path.normalize());
What is the result?
The normalize() method in the Path class removes redundant elements like '.' (current directory) and '..' (parent directory) from the path. Starting with the original path 'data\projects\a-project\..\..\another-project', the '..' components will move the path up two levels, effectively removing 'projects' and 'a-project'. The normalized path will point to 'data\another-project'.
A is true