Re: what is canonical path?

From: Ben Wan (bwan0425_at_rogers.com)
Date: 10/06/03


Date: Mon, 06 Oct 2003 04:54:26 GMT


"John Kordyback" wrote:
> getAbsolutePath returns the complete path to the file starting at the
> filesystem root.

if it returns a complete path then how come the following doesn't return the "absolute path"?
File f = new File(".");
f.getAbsolutePath(); // return "." and not "c:\folder\folder" ?
Thx.. ^_^

> getCanonicalPath returns the full path without aliases, shortcuts,
> shadows or symbolic links. getCanonicalPath resolves those aliases to
> their actual directories.
>
> getCanonicalPath throws an IOExceptions when the full path is not
> available (e.g. the disk in drive A is not ready or the user does not
> have access to the directory). It helps you catch errors before you
> write into the stream.
>
> /qb
>
>
> Ben Wan wrote:
> > Can anyone please tell me what is canonical path? and why does it need to throws IOexception?
> > how come getAbsolutePath() doesn't return "c:\folder\folder" but getCanonicalPath() does?
> > things I tried using java.io.File
> > file.getName(); // return "."
> > file.getAbsolutePath(); // return "."
> > file.getCanonicalPath(); // return "c:\folder\folder"
> >
> >
> > Thank You Very Much!
> >
> > Ben
> >
> >
>