Java File.getParent()
Syntax
File.getParent() has the following syntax.
public String getParent()
Example
In the following code shows how to use File.getParent() method.
// w w w . j a v a 2 s .com
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.getParent());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »