What is meant by canonical path and canonical file?

Ken Graham

First - both Absolute and Canonical forms are OS dependent per the API documentation for java.io.File.

Second - Absolute is not absolute. It is not a resolved path name. If File f is not already an absolute path name, according to OS dependent rules, then it simply prepends the value of System.getProperty("user.dir"). However, don't think that you can use setProperty("user.dir",otherdir), because it will be ignored under Windows. At some future point Sun may change their mind regarding this. :-)))))

Thirdly - Canonical is resolved, but in an OS dependent form.

Therefore, if you want to really know about the name of the file avoid either of these two methods, and use File.toURL().toExternalForm() instead. The form is resolved, and in an OS Independent way, so you can write code that is Write Once Run Anywhere.