本帖最后由 freehello 于 2015-8-29 21:06 编辑
- public class ServerTcp {
- public static void main(String[] args) throws Exception{
- ServerSocket ss = new ServerSocket(10000);
- Socket s = ss.accept();
- String str = null;
- BufferedReader bufR = new BufferedReader(new InputStreamReader(s.getInputStream()));
- while((str = bufR.readLine()) != null) {
- System.out.println(str);
- }
- }
复制代码- public class ServerTcp {
- ServerSocket ss = new ServerSocket(10000);
- while(true) {
- Socket s = ss.accept();
- String str = null;
- BufferedReader bufR = new BufferedReader(new InputStreamReader(s.getInputStream()));
- if((str = bufR.readLine()) != null)
- System.out.println(str);
- }
- }
- }
复制代码
|
|