public static byte[] encodingToBytes(final String str,final String encoding){
  if (str == null) {
    return null;
  }
  try {
    return str.getBytes(encoding);
  }
 catch (  final UnsupportedEncodingException e) {
    throw new Error(encoding + " not supported! Original exception: " + e);
  }
}

public static byte [ ] encodingToBytes ( final String str , final String encoding ) { if ( str == null ) { return null ; } try { return str . getBytes ( encoding ) ; } catch ( final UnsupportedEncodingException e ) { throw new Error ( encoding + " not supported! Original exception: " + e ) ; } }
convert a string to a byte array using the specified encoding .
