implement File.getParent()

This commit is contained in:
Joel Dice 2007-08-28 17:39:21 -06:00
parent f72f95d7ca
commit 8b102783a6

View File

@ -33,6 +33,20 @@ public class File {
return path; return path;
} }
public String getParent() {
int index = path.lastIndexOf("/");
if (index >= 0) {
return path.substring(0, index);
} else {
return null;
}
}
public File getParentFile() {
String s = getParent();
return (s == null ? null : new File(s));
}
private static native String toCanonicalPath(String path); private static native String toCanonicalPath(String path);
public String getCanonicalPath() { public String getCanonicalPath() {