public static byte[] toBytes(String str){
  return str.getBytes(StandardCharsets.UTF_8);
}

public static byte [ ] toBytes ( String str ) { return str . getBytes ( StandardCharsets . UTF_8 ) ; }
converts a string to a utf - 8 byte array .
