从套接字读取文本
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.Socket;/* 来自 时 代 J a v a 公 众 号 - nowjava.com*/ public class Main { public void main(String[] argv) { try { Socket socket = null; BufferedReader rd = new BufferedReader(new InputStreamReader( socket.getInputStream())); String str; while ((str = rd.readLine()) != null) { System.out.println(str);