Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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: 4637
50
  • 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: 4637
50
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic