Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getCanonicalPath vs getAbsolutePath  RSS feed

 
praveen likki
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am new to java servlets. i am looking at some code and in tht code people used getCanonicalPath. wht actually getCanonicalPath returns

please help me in this regard . i looked for old posts where people are saying tht canonical path returns short path where as absolute path retruns long path

but i havent understood wht this short path is and long path

so,please make me undertstand wht is canonical path and difference between canonicalpath abd absolute path

thanxs in advance
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Canonical Path is always an Absolute Path. But its not always true vice versa. Hence, its better to use canonical path while comparing values.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the IO forum.

Dave
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the API documentation says, in its obscure way, the canonical path is standardized from the absolute path like this:

"...removing redundant names such as "." and ".." from the pathname, resolving symbolic links (on UNIX platforms), and converting drive letters to a standard case (on Microsoft Windows platforms)..."

Both will probably work the same when you use them, but as Adeel says you might as well use the canonical path.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!