分享

工具类,方法

 藏经阁_苍穹 2015-11-29
一:
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);

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多