• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

getCanonicalPath & getAbsolutepath

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone explain me whats getCanonicalPath() and getAbsolutePath().
i read that getAbsolutePath() returns the absolute path including the parent directories and as well including the file name itself from where u onvoke this method.
for eg: C:\java\javastudy\file1.txt
is this correct?

how does getAbsolutePath() work?
please explain......
 
Enthuware Software Support
Posts: 4767
52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider that you have a file myfile.txt in c:\paul\java\temp
Now,
File f = new File("c:\paul\java\..\java\temp\myfile.txt");
f.absolutePath() is c:\paul\java\..\java\temp\myfile.txt and
f.canonicalPath() is c:\paul\java\temp\myfile.txt, you can see that there is no "redundancy" in canonical path.
HTH,
Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus

[This message has been edited by Paul Anil (edited February 13, 2001).]
 
Sai Ram9
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul i still didn't completely understand canonicalpath.
Redudancy in sense without any \.. or \. etc..?
what happens to the other java folder,
c:\paul\java\..\java\temp\myfile.txt
there are 2 java folders right?
 
Paul Anilprem
Enthuware Software Support
Posts: 4767
52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is only one java dir. java/../java implies, you go to java then go back one dir and again go to java. ( .. => parent dir, . => current dir )
HTH,
Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul!
 
You are HERE! The other map is obviously wrong. Better confirm with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic