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 ( ) ) ; }
Converts text content to binary .