转换字符串的字符集

来源:互联网 发布:网络电视突然不能看了 编辑:程序博客网 时间:2024/06/05 06:19
         /** * 转换字符串的字符集 * @param str要转换的字符串 * @param fromCharset初始字符集 * @param toCharset目标字符集 * @return转换后的字符串 */public static String transCharset(String str,String fromCharset,String toCharset){String temp = "";try {temp = new String(str.getBytes(fromCharset),toCharset);temp = temp.trim();} catch (UnsupportedEncodingException e) {e.printStackTrace();}return temp;}

原创粉丝点击