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