package heima.cmo;
import java.net.*;
import java.io.*;
public class recserSever {
public static void main(String[] args)throws Exception {
ServerSocket ss=new ServerSocket(3004);
boolean Rruning =true;
while(Rruning){
Socket s=ss.accept();
new Thread(new Servecis(s)).start();
}
ss.close();
}
}
class Servecis implements Runnable{
Socket s;
public Servecis(Socket s){
this.s=s;
}
public void run(){
try{
InputStream ips=s.getInputStream();
OutputStream ops=s.getOutputStream();
BufferedReader bff=new BufferedReader(new InputStreamReader(ips));
PrintWriter pw=new PrintWriter(ops);
while(true){
String str= bff.readLine();
if(str.equalsIgnoreCase("bye")){ break;
}
String sStr=new StringBuffer(str).reverse().toString();
pw.println(sStr);
}
bff.close();
pw.close();
s.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}java.lang.NullPointerException
at heima.cmo.Servecis.run(recserSever.java:31)
at java.lang.Thread.run(Unknown Source)
大家帮忙看看这段代码有什么不对的地方?为什么我在关闭客户端的时候红色标记的哪一行会出现这样的异常: |