• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Diff betw canonical and absolute

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the meaning of absolute path(or file) and canonical path (or file) and abstract path?
I am not able to understand the File methods because of this doubt. Can anybody explain please.. Thanks
[ February 15, 2005: Message edited by: Sue Pillai ]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We can create a file with a relative pathname:

That file, if it exists, is in the directory above the current working directory. Now if we want to know its path from the root directory, we use getAbsolutePath(). This method makes no attempt to resolve the path so it will be the curent working directory, two dots, then the file name (i.e. c:\java\..\test.txt). This could cause confusion should we attempt to create another file in the java directory with the same name:

Both of the files point to the same directory but the paths are different. This makes comparing files for equality (i.e. do two File instances represent the same physical file) impossible. getCanonicalPath() and getCanonicalFile() compute the path by resolving path operators (i.e. . and ..), symbolic links, drive letter case (on Windows) and so on such that a single file on a given file system has a single canonical path. We can use this canonical path (or instance, in the case of getCanonicalFile) to reliably test File instances for equality.
[ February 15, 2005: Message edited by: Joe Ess ]
 
Sue Pillai
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks again!! I get it now.
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic