static String shortenPathName(Path path, int bytes) {
    String pathString = path.toUri().getPath();
    String replaced = pathString.replace("/", "_");

    if (replaced.length() <= bytes) {
      return replaced;
    }

    int bytesPerHalf = (bytes - 3) / 2;
    return replaced.substring(0, bytesPerHalf) + "..." + replaced.substring(replaced.length() - bytesPerHalf);
  }
static String shortenPathName ( Path path , int bytes ) { String pathString = path . toUri ( ) . getPath ( ) ; String replaced = pathString . replace ( "/" , "_" ) ; if ( replaced . length ( ) <= bytes ) { return replaced ; } int bytesPerHalf = ( bytes - 3 ) / 2 ; return replaced . substring ( 0 , bytesPerHalf ) + "..." + replaced . substring ( replaced . length ( ) - bytesPerHalf ) ; }
Shorten an absolute path into a sanitized String of length at most bytes. This is useful for including a summary
of an absolute path in a file name.

<p>
For example: shortenPathName("/user/gobblin/foo/bar/myFile.txt", 25) will be shortened to "_user_gobbl..._myFile.txt".
</p>

@param path absolute {@link Path} to shorten.
@param bytes max number of UTF8 bytes that output string can use (note that,
for now, it is assumed that each character uses exactly one byte).
@return a shortened, sanitized String of length at most bytes.