getAbsolutePath returns the absolute i,e not relative path of the file or directory.
For example, the following code creates a file
'
test' in the directory directly above the
current directory which is C:\java\io
File f1 = new File("..", "test.txt")
f1.createNewFile();
System.out.println( f1.getAbsolutePath() );
Output:
C:\java\io\..\test
the canonical path is the same as the absolute path BUT all relative indicators . and .. are resolved
For example,
System.out.println( f1.getCanonicalPath() );
Output:
// '..' in absolute path is resolved
C:\java\test
getPath converts the abstract pathname into a pathname
string.
For example,
System.out.println( f1.getPath() );
Output:
..\test
Hope this helps......