NOTE
Path
Path represents a file-system path, with capabilities related to File. These notes use examples to record path creation and manipulation.
This is a historical learning note and may contain outdated or incomplete understanding.
What It Is
Represents a file path, similar to the File class.
Absolute Path
// Linux
Path path = Paths.get("<USER_HOME>/code/Java/my_spring_boot_template/pom.xml");
// Windows
Path path = Paths.get("c:\\data\\myfile.txt");
Path path = Paths.get("c:/data/myfile.txt");
Relative Path
Path path = Paths.get("<USER_HOME>/code/Java/my_spring_boot_template", "pom.xml");
Path currentDir = Paths.get(".");
Path parentDir = Paths.get("..");
String originalPath = "<USER_HOME>/code/Java/my_spring_boot_template/../";
Path path1 = Paths.get(originalPath);
System.out.println("path1 = " + path1);
Path path2 = path1.normalize();// Print the complete path
System.out.println("path2 = " + path2);
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub