

The java.io.File class has three methods to obtain the filesystem paths: C:\Users\lokesh\IdeaProjects\Core-Java\src\main\java\com\howtodoinjava\io\foo\foo.txtĬ:\Users\lokesh\IdeaProjects\Core-Java\src\main\java\com\howtodoinjava\io\foo\bar\bar.txt The canonical path of a file just “purifies” the path to the absolute path, removing and resolving stuff like dots and resolving symlinks (on UNIX). Canonical PathĬanonical paths are absolute paths after resolving the shorthands or redundant names like dots “. Absolute paths may contain the shorthands like single and double dots in the file paths.Ĭ:\Users\lokesh\IdeaProjects\Core-Java\src\main\java\com\howtodoinjava\io\foo\foo.txtĬ:\Users\lokesh\IdeaProjects\Core-Java\src\main\java\com\howtodoinjava\io\foo\bar\.\foo.txt 1.3.Absolute paths contain all the relevant information to find the resources indicated by an absolute URL.There is no more information required further to access the file or path.

Absolute PathĪn absolute path always contains the root element and the complete directory hierarchy required to locate the file.

Src\main\java\com\howtodoinjava\io\foo\bar\bar.txt 1.2. src\main\java\com\howtodoinjava\io\foo\foo.txt This is the path, which we generally provide in the File class’s constructor. Unlike absolute paths, relative paths contain information that is only relative to the current directory. Relative PathĪ relative path is a path that describes the location of a file or folder in relative to the current working directory. Relative, Absolute and Canonical Paths 1.1.
