code: public static byte[] convertTextToOctetStream(Object source, MediaType sourceType) {
        if (source == null) return null;
        if (sourceType == null) {
           throw new NullPointerException("MediaType cannot be null!");
        }
        if (source instanceof byte[]) return (byte[]) source;
        return source.toString().getBytes(sourceType.getCharset());
     }
docs: Converts text content to binary.
  
  @param source The source content.
  @param sourceType MediaType for the source content.
  @return content converted as octet-stream represented as byte[].
  @throws EncodingException if the source cannot be interpreted as plain text.