结果像这样:
第1个?ú??
第2个????????
第3个MySQL Newsletter: April 2005
第4个Sheesh, what was I thinking?
第5个IBM developerWorks 中国网站时事通讯:第 206 期 -- [2005-04-12]
第6个wenhua?s Students? Union Newsletter 6
第7个Serial number for Nokia Developer's Suite for the Java(TM) 2 Platform, Micro Edition, Version 2.2 for Windows installation
第8个帐号注册成功 @ E维论坛
第9个ITPUB×???????_2005.4.7
第10个网站建设1180元起
第1个?ú??
第2个????????
第3个MySQL Newsletter: April 2005
第4个Sheesh, what was I thinking?
第5个IBM developerWorks 中国网站时事通讯:第 206 期 -- [2005-04-12]
第6个wenhua?s Students? Union Newsletter 6
第7个Serial number for Nokia Developer's Suite for the Java(TM) 2 Platform, Micro Edition, Version 2.2 for Windows installation
第8个帐号注册成功 @ E维论坛
第9个ITPUB×???????_2005.4.7
第10个网站建设1180元起
String str = null ;
MimeMessage message = null;
for(int i=0;i<ms.length;i++){
message=ms[i];
str += "第" + i + "个" + parseSubject(message.getHeader("Subject",null))+" \n";
}
System.out.println(str)
//再一个转换方法如下:
public static String parseSubject(String string){
String str = "";
if(string==null)return "";
try {
if(string.startsWith("=?GB")||string.startsWith("=?gb")){
str=MimeUtility.decodeText(string);
}else {
str = charTogb(MimeUtility.decodeText(string));
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return str;
}
按以上方式保证可以搞定.我试过了.
你也可以到http://www.open-open.com找几个开源Email研究一下.
public static String charTogb(String string) throws UnsupportedEncodingException{
return new String(string.getBytes("ISO-8859-1"),"GBK");
}