code: public static String getParent(String path) {
          String parent = null;
          if (path.lastIndexOf('/') != -1) {
              if (path.length() == 1) {
                  parent = null;
              } else if (path.lastIndexOf('/') == path.indexOf("/") && path.indexOf("/") == 0) {
                  parent = "/";
              } else {
                  parent = path.substring(0, path.lastIndexOf("/"));
              }
          }
          return parent;
      }
docs: Gets the parent section of a given path.
  <p>
  Eg, for /wibble/fish/monkey, will return /wibble/fish<br>
  for /wibble, will return /<br>
  for / will return null
  
  @param path the path to be interpreted.
  @return parent path, or null if there is no parent path possible.