uri的深度计算

    public int depth(URI uri) {
        String path = uri.getPath();
        int depth = 0;
        int slash = path.length() == 1 && path.charAt(0) == '/' ? -1 : 0;
        while (slash != -1) {
            depth++;
            slash = path.indexOf("/", slash + 1);
        }
        return depth;
    }

你可能感兴趣的:(uri的深度计算)