public static String encoding(final String source, final String sourceCharset,
    final String encodingCharset) throws IllegalArgumentException {

    byte[] sourceBytes;
    String encodeString = null;
    try {
      sourceBytes = source.getBytes(sourceCharset);
      encodeString = new String(sourceBytes, encodingCharset);
    } catch (UnsupportedEncodingException e) {
      throw new IllegalArgumentException(String.format("Unsupported encoding:%s or %s",
        sourceCharset, encodingCharset));
    }
    return encodeString;
  }
public static String encoding ( final String source , final String sourceCharset , final String encodingCharset ) throws IllegalArgumentException { byte [ ] sourceBytes ; String encodeString = null ; try { sourceBytes = source . getBytes ( sourceCharset ) ; encodeString = new String ( sourceBytes , encodingCharset ) ; } catch ( UnsupportedEncodingException e ) { throw new IllegalArgumentException ( String . format ( "Unsupported encoding:%s or %s" , sourceCharset , encodingCharset ) ) ; } return encodeString ; }
Return encoded string by given charset.

@param source source string to be handle.
@param sourceCharset source string charset name.
@param encodingCharset want encoding to which charset.
@return a new string has been encoded.
@throws IllegalArgumentExceptionWORD_PATTERN If the named charset is not
supported