Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between getAbsolutePath() and getCanonicalPath()

 
Kevin Simonson
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I take a look at "http://docs.oracle.com/javase/7/docs/api/" for the documentation on class {File}, there's a method there named {getAbsolutePath()} that returns "the absolute pathname string of this abstract pathname." There's also a method named {getCanonicalPath()} that returns "the canonical pathname string of this abstract pathname." Furthermore, it says a "canonical pathname is both absolute and unique." On a Windows 7 system, when would {getAbsolutePath()} ever return anything different from what {getCanonicalPath()} does?
 
Rob Spoor
Sheriff
Pie
Posts: 20529
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Kevin Simonson
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:

Wow, I see. That's quite a difference!
 
sai rama krishna
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is only one canonical path to a file, while there can be many absolute paths to a file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic