PathTools { public static String evaluatePath(String path) { List<String> pathStack = getPathStack(path, true); return getPathStackString(pathStack); } 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 evaluatePath() throws Exception { internalEvaluatePath("", ""); internalEvaluatePath("/", "/"); internalEvaluatePath("/foo/bar", "/foo/bar"); internalEvaluatePath("foo/bar", "foo/bar"); internalEvaluatePath("/foobar/../foo/bar", "/foo/bar"); internalEvaluatePath("/foo/bar/../foobar/..", "/foo"); internalEvaluatePath("/foo/bar/...../foobar", ".../foobar"); internalEvaluatePath("/foo/bar/../foobar", "/foo/foobar"); internalEvaluatePath("/foo/bar/..../foobar", "../foobar"); }