1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| 2. package cn.cduestc.fire;
import java.io.IOException; import java.io.InputStream; import java.net.Socket;
public class ClientOutputThread extends Thread{ private Socket socket;
public ClientOutputThread(Socket s) { socket = s; }
@Override public void run(){ try { InputStream is=socket.getInputStream(); byte[]buffer=new byte[1024]; int length; while(true) { length = is.read(buffer); String str = new String(buffer, 0, length); System.out.println(str); } } catch (IOException e) { e.printStackTrace(); } } }
|