Get the Parents of a Filename Path in Java
Description
The following code shows how to get the Parents of a Filename Path.
Example
// ww w . jav a2 s . c o m
import java.io.File;
public class Main {
public static void main(String[] argv) throws Exception {
File file = new File("test.java");
String parentPath = file.getParent();
System.out.println(parentPath);
File parentDir = file.getParentFile();
System.out.println(parentDir);
}
}
The code above generates the following result.