出什么问题?(为什么可以编译,不能运行?)

xiaomaju 2002-07-17 10:19:45
import java.io.*;
import java.net.*;
import java.util.*;


class ClientCon implements Runnable{
protected Socket Clientsocket=null;//定义一个用来连接的socket
protected DataOutputStream outStream=null;
protected DataInputStream inStream=null;
protected int port=9999;//端口号

public ClientCon(String hostname) throws IOException {

Clientsocket =new Socket(hostname,port);
outStream=new DataOutputStream(Clientsocket.getOutputStream());
inStream=new DataInputStream(Clientsocket.getInputStream());
}

protected void closeCon(){
try{
Clientsocket.close();
}catch(Exception oops){}
}
public void run (){
while(true){
try{
String str=inStream.readUTF();
System.out.println(str);

}catch(Exception exp){
}


}
}
//发送字符串
protected void sendMessage(String meg){
try{
outStream.writeUTF(meg);
}catch(Exception expt){
System.out.println("shit");

}
}
public static void main(String[] args){
try{
ClientCon con =new ClientCon("202.118.103.193");
con.sendMessage("logIn%$%xiaoma");
System.out.println("OK");
con.run();
}catch(Exception exp){
System.out.println("fuck");
}
}
}

在线等待,谢谢!

...全文
47 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangbin_zhang 2002-07-17
  • 打赏
  • 举报
回复
哈哈!有异常,再看看吧!
zhangbin_zhang 2002-07-17
  • 打赏
  • 举报
回复
没问题,我可以运行。输出“fuck”.

62,614

社区成员

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

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