javamail_接收邮件_pop3接收邮件乱码问题
private static Pattern p1=Pattern.compile(".*",Pattern.CASE_INSENSITIVE); private static Matcher m=null; private static Matcher m1=null; public static String getChinese(String str){ String rtnStr=""; m=p.matcher(str); m1=p1.matcher(str); try { if (m.find()) { if (m.group(1)!=null) { rtnStr=MimeUtility.decodeText(m.group(0)); }else if (m.group(5)!=null){ //rtnStr="为定义的名字"; rtnStr=new String(m.group(0).getBytes("iso-8859-1")); } }else if(m1.find()){ //System.out.println(m1.find()); rtnStr=new String(m1.group().getBytes("iso-8859-1")); } } catch (Exception e) { rtnStr=str; e.printStackTrace(); } System.out.println(rtnStr); return rtnStr; }
public static String getSubChinese(String str){ String rtnStr=""; try { rtnStr=new String(str.getBytes("iso-8859-1")); if (rtnStr.contains("=")) { rtnStr=MimeUtility.decodeText(str); } } catch (UnsupportedEncodingException e) { rtnStr=str; e.printStackTrace(); } System.out.println(rtnStr); return rtnStr; }}
?
?