This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hey guys...after reading many posts from javaranch and many other websites, I'm still not able to get the difference between Canonical and Absolute Path....so i wrote a program...
The output of the program is
The parent directory is C:\Directory\..\.
The path of the directory is C:\Directory\..\.\abc
The absolute path is C:\Directory\..\.\abc
The canonical path is C:\abc
I guess this program should create 2 directories one is "Directory" and "ABC" which should be inside "Directory" directory but it's creating only one which is "abc"...i'm not getting this Absolute and Canonical path thing...
Any help ....
Within File, the absolute path is not much more than the current folder added to the front of the path as you created the File with. For instance, if you create a new File("folder/../other") while your current folder is "D:\Temp", the absolute path will be "D:\\Temp\\folder\\..\\other".
The canonical file will ask the file system what the actual file path is. ".." means going up one path, "." means the current folder. In your case, It takes folder "C:\\Directory"", goes one up from that (resulting in "C:\\"), then goes to the same folder ("C:\\"), then goes to sub folder "abc" ("C:\\abc").
Note that you don't create any files or directories this way. They are all just names. Use mkdir() or mkdirs() to actually create directories.
Could you please explain me..what's the meaning of ".." and ".", while creating a directory or a file...
And in the program above...it only creates one directory which is "abc", i though it'll create two..directory 1. Directory 2. ABC.