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