救急!!!请帮我看看这段程序?为什么还是乱码?
wxyxl 2001-04-19 09:50:00 import java.io.*;
import java.net.*;
public class Pop3test
{
public static void main(String[] args)
{
try{
Socket s = new Socket(args[0],110);
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
String str;
str = in.readLine();
System.out.println("初始化结果"+str);
out.write("USER wxyxl\n");
out.flush();
str = in.readLine();
System.out.println("用户名输入结果 "+str);
out.write("pass wxyxl78\n");
out.flush();
str = in.readLine();
System.out.println("密码输入结果 "+str);
out.write("list\n");
out.flush();
str = in.readLine();
System.out.println("List "+str);
int i=0;
while((str = in.readLine()) != null)
{
System.out.println(str);
if (!(str.equals(".")))
{
i++;
}
else
break;
}
System.out.println("共有 "+i+" 封邮件");
String result = "";
byte[] b;
for (int j=1;j<=i;j++)
{
out.write("RETR "+j+"\n");
out.flush();
while (((str = in.readLine()) != null) &&(!(str.equals("."))))
{
b = str.getBytes("GB2312");
str = new String(b,"8859_1");
result += str + "\n";
}
System.out.println("这是第 "+j+" 封邮件");
System.out.println(result);
System.out.println("*************************");
}
s.close();
}catch(Exception e)
{}
}
}
程序的输出结果如下:
初始化+OK X1 NT-POP3 Server wxyxl.com (IMail 4.06 519-1)
用户名输入 +OK welcome
密码输入 +OK maildrop locked and ready
List +OK 1 messages (669 octets)
1 669
.
共有 1 封邮件
这是第 1 封邮件
+OK 669 octets
Received: from xieli [128.8.1.2] by wxyxl.com
(SMTPD32-4.06) id A06AA0878; Thu, 19 Apr 2001 21:51:54 PDT
Date: Thu, 19 Apr 2001 21:51:54 +0800
From: =?ISO-8859-1?Q?=CD=F5=CF=FE=D2=E5?= <xlwxy@wxyxl.com>
To: =?ISO-8859-1?Q?=D0=BB=C0=F6?= <wxyxl@wxyxl.com>
Subject:
X-mailer: FoxMail 3.1 [cn]
Mime-Version: 1.0
Content-Type: text/plain; charset="GB2312"
Content-Transfer-Encoding: quoted-printable
X-UIDL: 987714525
Status: U
=D0=BB=C0=F6=A3=AC=C4=FA=BA=C3=A3=A1
Three Email!
=D6=C2
=C0=F1=A3=A1
=CD=F5=CF=FE=D2=E5
xlwxy@wxyxl.com
*************************
我不懂的是为什么我在接受数据的时候已经坐了编码转换,
为什么还是乱码呢,请高手指教!