1. 首页
  2. 编程语言
  3. Java
  4. java聊天程序有用

java聊天程序有用

上传者: 2019-04-10 04:59:19上传 JAVA文件 6.11KB 热度 26次
主要就是只用这个进行通讯 try { Socket socekt=new Socket("127.0.0.1",1032); InputStreamReader isr=new InputStreamReader(socekt.getInputStream()); BufferedReader br=new BufferedReader(isr); pw=new PrintWriter(socekt.getOutputStream(),true); while(true){ String message=br.readLine(); jta.append(message+"\n"); } } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
用户评论