Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between getAbsolutePath() and getCanonicalPath()  RSS feed

 
Kevin Simonson
Ranch Hand
Posts: 198
1
  • 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
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Kevin Simonson
Ranch Hand
Posts: 198
1
  • 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: 524
1
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!