当前位置: 技术问答>java相关
请教一个简单的问题!
来源: 互联网 发布时间:2015-04-27
本文导语: import java.io.*; import java.net.*; class TextServer { public static void main(String argv[]) { int port=1000; Socket Client; String msg; BufferedReader in; BufferedReader input; PrintWriter out; try { Client=new Socket("163.net",110); input=new Buffered...
import java.io.*;
import java.net.*;
class TextServer
{
public static void main(String argv[])
{
int port=1000;
Socket Client;
String msg;
BufferedReader in;
BufferedReader input;
PrintWriter out;
try
{
Client=new Socket("163.net",110);
input=new BufferedReader(new InputStreamReader(System.in));
in=new BufferedReader(new InputStreamReader(Client.getInputStream()));
out=new PrintWriter(Client.getOutputStream(),true);
System.out.println(in.readLine());
System.out.println("Please Input Your UserName:");
msg=input.readLine();
out.println("USER "+msg);
System.out.println(in.readLine());
System.out.println("Please Input Your Password:");
msg=input.readLine();
out.println("PASS "+msg);
msg=in.readLine();
System.out.println(msg);
out.println("RETR 1");
msg=in.readLine();
while(msg!="")
{
System.out.println(msg);
msg=in.readLine();
}
}catch(IOException e){System.exit(-1);};
}
}
这是我写的一个程序,想收163邮箱的第一封信件,但是这个循环
while(msg!="")
{
System.out.println(msg);
msg=in.readLine();
}
总是不能终止,请教高手这是为什么?还有就是我想让输入密码的时候不显示,该怎么写?谢谢!
import java.net.*;
class TextServer
{
public static void main(String argv[])
{
int port=1000;
Socket Client;
String msg;
BufferedReader in;
BufferedReader input;
PrintWriter out;
try
{
Client=new Socket("163.net",110);
input=new BufferedReader(new InputStreamReader(System.in));
in=new BufferedReader(new InputStreamReader(Client.getInputStream()));
out=new PrintWriter(Client.getOutputStream(),true);
System.out.println(in.readLine());
System.out.println("Please Input Your UserName:");
msg=input.readLine();
out.println("USER "+msg);
System.out.println(in.readLine());
System.out.println("Please Input Your Password:");
msg=input.readLine();
out.println("PASS "+msg);
msg=in.readLine();
System.out.println(msg);
out.println("RETR 1");
msg=in.readLine();
while(msg!="")
{
System.out.println(msg);
msg=in.readLine();
}
}catch(IOException e){System.exit(-1);};
}
}
这是我写的一个程序,想收163邮箱的第一封信件,但是这个循环
while(msg!="")
{
System.out.println(msg);
msg=in.readLine();
}
总是不能终止,请教高手这是为什么?还有就是我想让输入密码的时候不显示,该怎么写?谢谢!
|
while(msg!=null)