code: private Path makeRelative(String initial, Path p) {
      String scheme = this.uri.getScheme();
      String authority = this.uri.getAuthority();
      Path root = new Path(Path.SEPARATOR);
      if (root.compareTo(p) == 0)
        return new Path(scheme, authority, initial);
      Path retPath = new Path(p.getName());
      Path parent = p.getParent();
      for (int i=0; i < p.depth()-1; i++) {
        retPath = new Path(parent.getName(), retPath);
        parent = parent.getParent();
      }
      return new Path(new Path(scheme, authority, initial),
        retPath.toString());
    }
docs: just use the path api to do it.