public static Path makeRelative(Path parentPath, Path childPath) {
    String parentString =
        parentPath.toString().endsWith(Path.SEPARATOR) ? parentPath.toString() : parentPath.toString() + Path.SEPARATOR;
    String childString =
        childPath.toString().endsWith(Path.SEPARATOR) ? childPath.toString() : childPath.toString() + Path.SEPARATOR;
    return new Path(childString.replaceFirst(parentString, ""));
  }
Returns a relative path wrt the parent path.
@param parentPath the parent path.
@param childPath the child path.
@return childPath relative to parent path.
common/src/java/org/apache/hadoop/hive/common/FileUtils.java