code: static String makeRelative(Path root, Path absPath) {
      if (!absPath.isAbsolute()) {
        throw new IllegalArgumentException("!absPath.isAbsolute(), absPath="
            + absPath);
      }
      String p = absPath.toUri().getPath();
  
      StringTokenizer pathTokens = new StringTokenizer(p, "/");
      for(StringTokenizer rootTokens = new StringTokenizer(
          root.toUri().getPath(), "/"); rootTokens.hasMoreTokens(); ) {
        if (!rootTokens.nextToken().equals(pathTokens.nextToken())) {
          return null;
        }
      }
      StringBuilder sb = new StringBuilder();
      for(; pathTokens.hasMoreTokens(); ) {
        sb.append(pathTokens.nextToken());
        if (pathTokens.hasMoreTokens()) { sb.append(Path.SEPARATOR); }
      }
      return sb.length() == 0? ".": sb.toString();
    }
docs: Make a path relative with respect to a root path.
  absPath is always assumed to descend from root.
  Otherwise returned path is null.