The getCanonicalFile() method returns the canonical form of the file or directory. Equivalent to new File(file.getCanonicalPath()) method.
2. Method signature
method does not take any parameter
File - the canonical pathname of the specified file or directory
IOException - in case an I/O error occurs
SecurityException - when we do not have access to the file or directory
3.1. Program that compares getCanonicalFile() and getAbsoluteFile() methods
In this article, we presented File.getCanonicalFile() method that can be used to get the canonical representation of the file or directory. This method is behavior is similar to getCanonicalPath() with the difference in the result object.