code: public static String truncate(String string, int maxBytesLength) {
          byte[] stringBytes = string.getBytes();
          return stringBytes.length > maxBytesLength
                  ? new String(stringBytes, 0, maxBytesLength - 1) : string;
      }
docs: Truncate string.
  
  @param string         the string
  @param maxBytesLength the max bytes length
  @return the string