Java File.getAbsoluteFile()
Syntax
File.getAbsoluteFile() has the following syntax.
public File getAbsoluteFile()
Example
In the following code shows how to use File.getAbsoluteFile() method.
//from w w w. j a v a2s .com
import java.io.File;
public class Main {
public static void main(String[] args) throws Exception{
File f = new File("test.txt");
// create new file in the system
f.createNewFile();
// create new file object from the absolute path
File f1 = f.getAbsoluteFile();
System.out.println(f1);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »