code: private static byte[] stringToBytes(String text) {
          byte[] data;
          try {
              data = text.getBytes(Charset.forName(StandardCharsets.UTF_8.name()));
          } catch (UnsupportedCharsetException ex) {
              data = text.getBytes(Charset.defaultCharset());
          }
          return data;
      }
docs: Converts the given text into bytes.
  
  @param text the text to convert
  @return the bytes