Constructor Summary File(File parent, String child)
Creates a new File instance from a parent abstract pathname and a child pathname string.
Creates a new File instance by converting the given pathname string into an abstract pathname.
File(String parent, String child)
Creates a new File instance from a parent pathname string and a child pathname string.
i'am having hard time understanding their descriptions. for e.g in the first case what does "creates a file instance froma parent abstract pathname and a child pathname string " means.
secondly what is the difference between getAbsolutePath() and getCanonicalPath() methods ?
A lot of confusion arises from the fact that the File class doesn't actually represent files. It represents pathnames. This error was more or less corrected when the designers introduced java.nio.file.Path to replace java.io.File.
When you construct a path from a parent and child path, it simply means that the new path is a concatenation of the two paths. For instance, consider "C:\\Program Files\\Java" and "jre7\\bin". When you construct a new File object using these two paths, you will get an object representing "C:\\Program Files\\Java\\jre7\\bin".
Canonical paths are absolute paths that are also unique. You usually get them by resolving symbolic links. For instance, the path "C:\\Test\\..\\test.txt" is absolute, but it's not canonical. If you call getCanonicalPath() on the object representing this path, you would get one that represents "C:\\test.txt".