code: public static String pathOnly(String path)
     {
        String curPath = path;
        curPath = curPath.substring(curPath.indexOf("/"));
        curPath = curPath.substring(0, curPath.lastIndexOf("/"));
        if ("".equals(curPath))
        {
           curPath = "/";
        }
        return curPath;
     }
docs: Cuts the path from string.
  
  @param path full path
  @return relative path.