code: public static byte[] getBytes(String string) {
      byte[] result = new byte[utf8Length(string)];
      try {                                         // avoid sync'd allocations
        writeChars(result, string, 0, string.length());
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return result;
    }
docs: Convert a string to a UTF-8 encoded byte array.
  @see String#getBytes(String)