/** * 字符串编码转换的实现方法 * @param str 待转换的字符串 * @param newCharset 目标编码 */ public String changeCharset(String str, String newCharset) throws UnsupportedEncodingException { if(str != null) { //用默认字符编码解码字符串。与系统相关,中文windows默认为GB2312 byte[] bs = str.getBytes(); return new String(bs, newCharset); } return null; } 转载于:https://my.oschina.net/haquanwen/blog/96808