class PathUtils {

    public static int getDepth(String path, String separator) {
        if(path.equals("") || path.equals(separator))
            return 0;

        int depth = 1;
        int pos = path.startsWith(separator)?1:0;

        while ((pos=path.indexOf(separator, pos+1))!=-1)
            depth++;

        if(path.endsWith(separator))
            depth--;

        return depth;
    }

}