PathTools { public static String getParentPath(String path) { return evaluatePath(resolvePath(path, "..")); } private  PathTools(); static String resolvePath(String basePath, String path); static String evaluatePath(String path); static String getAbsolutePath(String basePath, String path); static String getParentPath(String path); static String getCompatiblePath(String path); static boolean isDotPattern(String s); static List<String> getPathStack(String path, boolean evaluateDots); static String getPathStackString(List<String> pathStack);  }
@Test public void getParentPath() throws Exception { internalGetParentPath("", ".."); internalGetParentPath(".", ".."); internalGetParentPath("/", ".."); internalGetParentPath("/foo/bar", "/foo"); internalGetParentPath("foo/bar", "foo"); internalGetParentPath("/foobar/../foo/bar", "/foo"); internalGetParentPath("/foo/bar/../foobar", "/foo"); internalGetParentPath("/foo/bar/..x/foobar", "/foo/bar/..x"); internalGetParentPath("/foo/bar/../foobar/..", "/"); internalGetParentPath("/foo/bar/..../foobar", ".."); }