File GetCanonicalPath() Example
Returns the canonical pathname string of this abstract pathname.
File class GetCanonicalPath() method example. This example shows you how to useGetCanonicalPath method.This method Returns the canonical pathname string of this abstract pathname.
Here is the code:-
/**
* @Program that Returns the canonical pathname string of this abstract pathname.
* GetCanonicalPath.java
* Author:-RoseIndia Team
* Date:-30-May-2008
*/
import java.io.*;
public class GetCanonicalPath {
public static void main(String[] args) throws IOException {
File f = new File("/home/girish/Desktop/g.txt");
if (f.exists()) {
System.out.println("Canonical Pathname is: " + f.getCanonicalPath());
} else {
System.out.println("File does not exists");
}
}
} |
Output of the Program
| Canonical Pathname is: /home/girish/Desktop/g.txt |
|