Java File.getParentFile()
Syntax
File.getParentFile() has the following syntax.
public File getParentFile()
Example
In the following code shows how to use File.getParentFile() method.
/*from ww w.ja v a2s . c om*/
import java.io.File;
public class Main {
public static void main(String[] args) throws Exception {
// create new files
File f = new File("c:/asdf/");
System.out.print(f.getParentFile());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »