src/org/nutz/lang/util/Disks.java
public static String getCanonicalPath(String path) {
        if (Strings.isBlank(path))
            return path;
        String[] pa = Strings.splitIgnoreBlank(path, "[\\\\/]");
        LinkedList<String> paths = new LinkedList<String>();
        for (String s : pa) {
            if ("..".equals(s)) {
                if (paths.size() > 0)
                    paths.removeLast();
                continue;
            }
            if (".".equals(s)) {
                // pass
            } else {
                paths.add(s);
            }
        }

        StringBuilder sb = Lang.concat("/", paths);
        if (path.startsWith("/"))
            sb.insert(0, '/');
        if (path.endsWith("/"))
            sb.append('/');
        return sb.toString();
    }
public static String getCanonicalPath(String path) {
        if (Strings.isBlank(path))
            return path;
        String[] pa = Strings.splitIgnoreBlank(path, "[\\\\/]");
        LinkedList<String> paths = new LinkedList<String>();
        for (String s : pa) {
            if ("..".equals(s)) {
                if (paths.size() > 0)
                    paths.removeLast();
                continue;
            }
            if (".".equals(s)) {
                // pass
            } else {
                paths.add(s);
            }
        }

        StringBuilder sb = Lang.concat("/", paths);
        if (path.startsWith("/"))
            sb.insert(0, '/');
        if (path.endsWith("/"))
            sb.append('/');
        return sb.toString();
    }
整理路径。 将会合并路径中的 ".."

@param path
路径
@return 整理后的路径