如何把Content-Type: application/octet-stream的"=?gb2312?B?seCzzMu8z+u1xNPW0ru0zrjvw/w=?="转化为中文.

Tarloy 2001-10-16 03:48:44


=?gb2312?B?seCzzMu8z+u1xNPW0ru0zrjvw/w=?=


是一个中文字符的octet-stream值
...全文
225 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tarloy 2001-10-18
  • 打赏
  • 举报
回复
谢谢,请查收.
gxj0637 2001-10-17
  • 打赏
  • 举报
回复
给分
gxj0637 2001-10-17
  • 打赏
  • 举报
回复
import com.sun.mail.util.*;

public static String decodeWord(String s)
{
if(!s.startsWith("=?"))
return s;
int i = 2;
int j;
if((j = s.indexOf(63, i)) == -1)
return s;
String s1 = (s.substring(i, j));
i = j + 1;
if((j = s.indexOf(63, i)) == -1)
return s;
String s2 = s.substring(i, j);
i = j + 1;
if((j = s.indexOf("?=", i)) == -1)
return s;
String s3 = s.substring(i, j);
try
{
ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(s3.getBytes());
Object obj;
if(s2.equalsIgnoreCase("B"))
obj = new BASE64DecoderStream(bytearrayinputstream);
else
if(s2.equalsIgnoreCase("Q"))
obj = new QDecoderStream(bytearrayinputstream);
else
return s;
int k = bytearrayinputstream.available();
byte abyte0[] = new byte[k];
k = ((InputStream) (obj)).read(abyte0, 0, k);
return new String(abyte0, 0, k );
}
catch(Exception ex)
{
return s;
}
}

:需下载一个javaMail
下载网址:java.sun.com
Jneu 2001-10-17
  • 打赏
  • 举报
回复
gz
Tarloy 2001-10-17
  • 打赏
  • 举报
回复
高人呢,都放假了吗?

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧