一:
public class ChinaEncode {
/** * @Description:中文编码异常转换 * @return String */ public static String encoding(String str){ String result = null; try { result = new String(str.getBytes("iso-8859-1"),"utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block new RuntimeException("编码转换失败"); } return result; } //或者 public static String encoding(String str){ java.net.URLEncoder.encode(str,"UTF-8"); } 二: String[] stringArray = org.springframework.util.StringUtils.delimitedListToStringArray((String) arguments,","); 三:简繁转换,汉拼音转换 import net.sf.chineseutils.ChineseUtils; import net.sourceforge.pinyin4j.PinyinHelper; import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; ChineseUtils.simpToTrad(word); ChineseUtils.tradToSimp(word); |
|