| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2374 人关注过本帖
标题:第五行有越界问题,不知如何解决
取消只看楼主 加入收藏
七小袋
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2015-11-20
结帖率:83.33%
收藏
已结贴  问题点数:20 回复次数:1 
第五行有越界问题,不知如何解决
import *;
import *;
public class lianxi51 {
    public static void main(String[ ] args)throws UnknownHostException,IOException{
        String name=args[0];
        Socket s=new Socket(InetAddress.getLocalHost(),6666);
        DataOutputStream dos=new DataOutputStream(s.getOutputStream());
        DataInputStream dis=new DataInputStream(s.getInputStream());
        new Thread(new ReceiveMessage(dis)).start();
        new Thread(new SendMessage(dos,name)).start();
    }
}
class ReceiveMessage extends Thread{
    private DataInputStream dis;
    public ReceiveMessage(DataInputStream dis){
        this.dis=dis;
    }
    public void run(){
        try{
            System.out.println(dis.readUTF());
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}
class SendMessage extends Thread{
    private DataOutputStream dos;
    private String name;
    public SendMessage(DataOutputStream dos,String name){
        this.dos=dos;
        this.name=name;
    }
    public void run(){
        String info;
        InputStreamReader is=new InputStreamReader(System.in);
        BufferedReader bf=new BufferedReader(is);
        while(true){
            try{
                info=bf.readLine();
                dos.writeUTF(name+":"+info);
            }catch (IOException e){
                e.printStackTrace();
            }
        }
    }
}
搜索更多相关主题的帖子: start 五行 import public Socket 
2015-12-11 15:35
七小袋
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2015-11-20
收藏
得分:0 
奈何没人能看出来
2015-12-11 16:00
快速回复:第五行有越界问题,不知如何解决
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015921 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved