How to encode the attachment's filename to gb2312 when sending and receiving mail?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Fenny_Yu
Posted On:   Friday, April 13, 2001 02:26 AM

I can't get the proper filename of Chinese when sending and receiving mail. How to get it?

Re: How to encode the attachment's filename to gb2312 when sending and receiving mail?

Posted By:   s_zh  
Posted On:   Monday, July 9, 2001 07:44 PM

This code can help you:

try {
content = msg.getContent()+"";
} catch
(UnsupportedEncodingException uex) {
InputStream is = msg.getInputStream();
content = convertToStr(is);
} catch (Exception ex) {
}

public String
convertToStr(InputStream ins) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(ins,"gb2312"));
String strr="",str="";
while((strr=br.readLine())!=null){
str = str + strr;
}
return str;
}


contact:goodszh@sohu.com from china
About | Sitemap | Contact