getCanonicalPath « API « Java I/O Q&A

1. File.getCanonicalPath() failure examples

Does anyone have an experience or know when the method File.getCanonicalPath() will throw an IOException I have tried to look up from the Internet and the best answer is in

2. What is the different between getAbsolutePath and getCanonicalPath

Java Newbie question : what is the different between getAbsolutePath() and getcanonicalPath() in file class. I can't get the meaning from the documents. in below code, their output are the same.

public ...

3. Why getCanonicalPath throws checked exception while getAbsolutePath does not?

I know the differences between the two by reading some related text. But I am curious that why getCanonicalPath() throws checked exception while getAbsolutePath() does not throw any?

4. File.getCanonicalPath

Hai Rahul By reading this example you can know difference between absolutepath and canonical path Assume that you have a text file in c:\windows\jcp\file1.txt,you compile and run the file in d:\somename\some> File f=new File("../jcp/file1.txt"); System.out.println("ab path"+f.getAbsolutePath());//this will return d:\somename\some..\jcp\file1.txt System.out.println("ca path"+f.getCanaonicalPath());//this will return d:\somename\jcp\file1.txt if u give like this File f1=new File("file.txt")both the answers will be same.

5. getCanonicalPath() and getAbsolutePath()

I have tried the above two methods using all possible forms of the File object . eg. File f = new File("abc.txt") File f = new File("\\dir1\\abc.txt") File f = new File("..\\dir1\\abc.txt") Can someone tell me exactly what these 2 methods do ? I seem to get unexplainable answers for all options when the aboce file "abc.txt" exists and when it ...

6. getCanonicalPath vs getAbsolutePath

i am new to java servlets. i am looking at some code and in tht code people used getCanonicalPath. wht actually getCanonicalPath returns please help me in this regard . i looked for old posts where people are saying tht canonical path returns short path where as absolute path retruns long path but i havent understood wht this short path is ...