code: public static int getPathLevel(String resource) {
  
          int level = -1;
          int pos = 0;
          while (resource.indexOf('/', pos) >= 0) {
              pos = resource.indexOf('/', pos) + 1;
              level++;
          }
          return level;
      }
docs: Returns the directory level of a resource.<p>
  
  The root folder "/" has level 0,
  a folder "/foo/" would have level 1,
  a folfer "/foo/bar/" level 2 etc.<p>
  
  @param resource the resource to determine the directory level for
  @return the directory level of a resource