Java File.getCanonicalFile()
Syntax
File.getCanonicalFile() has the following syntax.
public File getCanonicalFile() throws IOException
Example
In the following code shows how to use File.getCanonicalFile() method.
//from w w w . j a v a 2 s. c om
import java.io.File;
public class Main {
public static void main(String[] args) throws Exception {
// create new files
File f = new File("test.txt");
File path = f.getCanonicalFile();
System.out.print("Absolute Pathname " + path);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »