应该是想把socket和线程一一对应起来吧

解决方案 »

  1.   

    从文件流中读数据
    然后向某地(socket)写127个字节的数据两个for都没有用
      

  2.   

    不大明白你的要求.
    public void start1(){
        int i;
        int r=0;
        byte[] b=new byte[(int)f.length()];//定义一个f文件长度的字节数组
        for(i=1;i<b.length;i++)//作循环没有什么处理
    {
        }
        System.out.println(i);//显示文件长度
        try{
         filein.read(b);//把filein文件流中的数据放到b字节数组
        for(i=1;i<b.length;i++){
          System.out.println(b[i]);
        }
         out.write(b,0,179);//把b字节数组的前180个字节通过socket发送出去
         s.close();//关闭socket
         System.out.print("over");
        }catch(Exception e){
            System.out.println(e.getMessage());
        }
      

  3.   

    不大明白你的要求
    public void start1(){
        int i;
        int r=0;
        byte[] b=new byte[(int)f.length()];//定义一个f文件长度的字节数组
        for(i=1;i<b.length;i++)//作循环没有什么处理
    {
        }
        System.out.println(i);//显示文件长度
        try{
         filein.read(b);//把filein文件流中的数据放到b字节数组
        for(i=1;i<b.length;i++){
          System.out.println(b[i]);
        }
         out.write(b,0,179);//把b字节数组的前180个字节通过socket发送出去
         s.close();//关闭socket
         System.out.print("over");
        }catch(Exception e){
            System.out.println(e.getMessage());
        }
      

  4.   

    public void start1(){
        int i;
        int r=0;
        byte[] b=new byte[(int)f.length()];//定义一个f文件长度的字节数组
        for(i=1;i<b.length;i++)//作循环没有什么处理
    {
        }
        System.out.println(i);//显示文件长度
        try{
         filein.read(b);//把filein文件流中的数据放到b字节数组
        for(i=1;i<b.length;i++){
          System.out.println(b[i]);
        }
         out.write(b,0,179);//把b字节数组的前180个字节通过socket发送出去
         s.close();//关闭socket
         System.out.print("over");
        }catch(Exception e){
            System.out.println(e.getMessage());
        }