A bit late, but better late than never.
The @Carlo answer is essentially correct, except that you must catch an exception if you use getBytes with a String parameter.
Here is a variation (of the getBytes call) that will not throw an exception:
final byte[] byteArray = "blammy".getBytes(StandardCharsets.UTF_8); final BytesMessage bytesMessage = session.createBytesMessage(); bytesMessage.writeBytes(byteArray);
The StandardCharsets class defines charsets that are guaranteed to be available on every implementation of the Java platform.
String.getBytes(Charset)?