网络编程聊天室------客户端接收
/**
* 客户端线程接收类
* @author
*
*/
public class ClientRecive extends Thread{
public Socket socket;
public ClientRecive(Socket socket) {
super();
this.socket = socket;
}
@Override
public void run() {
try {
while(true){
InputStream is = socket.getInputStream();
byte[] b = new byte[1024];
int len = is.read(b);
System.out.println(new String(b,0,len).trim());
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}