code: public static byte[] getBytes(String s, String encoding)
      {
          try
          {
              return s == null ? null : s.getBytes(encoding);
          }
          catch (UnsupportedEncodingException e)
          {
              throw new IllegalArgumentException(String.format("Encoding (%s) is not supported by your JVM", encoding), e);
          }
      }
docs: Convert a String into a byte[] with a particular encoding.
  Preferable used when the encoding is one of the guaranteed Java types
  and you don't want to have to catch the UnsupportedEncodingException
  required by Java
  
  @param s        string to encode into bytes
  @param encoding encoding to use