Java Newbie question : what is the different between getAbsolutePath() and getcanonicalPath() in file class. I can’t get the meaning from the documents. in below code, their output are the same.
public class copyFile {
public static void main(String[] args) throws IOException {
File inputFile = new File("/home/kit.ho/");
System.out.println("get AbsolutePath");
System.out.println(inputFile.getAbsolutePath());
System.out.println("get CanonicalPath");
System.out.println(inputFile.getCanonicalPath());
}
}
Suppose
/homewas actually a symbolic link to/usr/home. ThengetAbsolutePathwould still return/home/kit.ho/whereasgetCanonicalPathwould resolve the symlink and return/usr/home/kit.ho/.