convert string to byte java

Java
  String example = "Convert Java String";
  byte[] bytes = example.getBytes();
Source

Also in Java: