public UnixPath relativize(UnixPath other) {
    checkArgument(isAbsolute() == other.isAbsolute(), "'other' is different type of Path");
    if (path.isEmpty()) {
      return other;
    }
    PeekingIterator<String> left = Iterators.peekingIterator(split());
    PeekingIterator<String> right = Iterators.peekingIterator(other.split());
    while (left.hasNext() && right.hasNext()) {
      if (!left.peek().equals(right.peek())) {
        break;
      }
      left.next();
      right.next();
    }
    StringBuilder result = new StringBuilder(path.length() + other.path.length());
    while (left.hasNext()) {
      result.append(PARENT_DIR);
      result.append(SEPARATOR);
      left.next();
    }
    while (right.hasNext()) {
      result.append(right.next());
      result.append(SEPARATOR);
    }
    if (result.length() > 0 && !other.hasTrailingSeparator()) {
      result.deleteCharAt(result.length() - 1);
    }
    return new UnixPath(permitEmptyComponents, result.toString());
  }
public UnixPath relativize ( UnixPath other ) { checkArgument ( isAbsolute ( ) == other . isAbsolute ( ) , "'other' is different type of Path" ) ; if ( path . isEmpty ( ) ) { return other ; } PeekingIterator < String > left = Iterators . peekingIterator ( split ( ) ) ; PeekingIterator < String > right = Iterators . peekingIterator ( other . split ( ) ) ; while ( left . hasNext ( ) && right . hasNext ( ) ) { if ( ! left . peek ( ) . equals ( right . peek ( ) ) ) { break ; } left . next ( ) ; right . next ( ) ; } StringBuilder result = new StringBuilder ( path . length ( ) + other . path . length ( ) ) ; while ( left . hasNext ( ) ) { result . append ( PARENT_DIR ) ; result . append ( SEPARATOR ) ; left . next ( ) ; } while ( right . hasNext ( ) ) { result . append ( right . next ( ) ) ; result . append ( SEPARATOR ) ; } if ( result . length ( ) > 0 && ! other . hasTrailingSeparator ( ) ) { result . deleteCharAt ( result . length ( ) - 1 ) ; } return new UnixPath ( permitEmptyComponents , result . toString ( ) ) ; }
Returns {@code other} made relative to {@code path}.

@see java.nio.file.Path#relativize(java.nio.file.Path)