Louis I. answered 06/08/19
Computer Science Instructor/Tutor: Real World and Academia Experienced
The question revolves around the java.io.File core Java Class.
See example simple program and output below, but here's a reasonable definition for each.
1) Path - that file path string value that was passed to the File() constructor - see below.
2) Absolute Path - that file path string value after resolving the relative path to a full or absolute path - see below.
3) Canonical Path - goes one step beyond the absolute path name resolution, replace short-hand notations for current and parent directories, and symbolic links (short cuts) with the actual directory path - see below.
Note: if the path that was used to create the File object instance did not not reference a symbolic link or include and relative path notional such as ./ (current dir) or ../ (parent dir), then the Absolute and Canonical values will be the same.
// Test / POC Code
package my.package.path;
import java.io.File;
import java.io.IOException;
public class FilePathTester {
public static void main(String[] args) {
File file = new File("./poke.gif");
System.out.printf("Path = %s\n" ,file.getPath());
System.out.printf("Absolute Path = %s\n" ,file.getAbsolutePath());
try {
System.out.printf("Canoical Path = %s\n" , file.getCanonicalPath());
}
catch(IOException ioex) {
System.err.println(ioex);
}
}
}
Path = .\poke.gif
Absolute Path = C:\dev\workspaces_J\CSC330\.\poke.gif
Canoical Path = C:\dev\workspaces_J\CSC330\poke.gif