Java tutorial
//package com.java2s; import java.io.UnsupportedEncodingException; public class Main { public static String convertCharset(String str, String sourceCharset, String destCharset) { if (isBlank(str) || isBlank(sourceCharset) || isBlank(destCharset)) { return str; } try { return new String(str.getBytes(sourceCharset), destCharset); } catch (UnsupportedEncodingException e) { return str; } } public static boolean isBlank(String str) { return str == null || str.trim().length() == 0; } }