...
         }catch(BindException  be){
                  System.out.println("Unable  to    bind  port  "+listenPort);
              }catch(IOException  ioe){
                  System.out.println("Unable  to  instantiate  a  ServerSocket  on  port  "+listenPort);
              }
....
多了个catch

解决方案 »

  1.   

    readString.close();
                  stringWriter.close();你的程序先编译吧........
      

  2.   

    好像不是brainy说的问题。
    你的程序很怪,你是每接到一个连接,只发一个信息给对方,只从对方接收一次信息??
      

  3.   

    catch(IOException ioe){
            System.out.println("Unable to instantiate a ServerSocket on port "+listenPort);
          }
      

  4.   

    错误信息如下:
    ---------- javac ----------
    MyServer.java:33: 'class' or 'interface' expected
     public  void connectionhandler(Socket incoming){
             ^
    MyServer.java:60: 'class' or 'interface' expected
    }
    ^
    MyServer.java:60: 'class' or 'interface' expected
    }
     ^
    MyServer.java:22: cannot resolve symbol
    symbol  : method connectionhandler  (java.net.Socket)
    location: class MyServer
        connectionhandler(incoming);
        ^
    4 errors
    Normal Termination
    输出完成(耗时 6 秒)。
      

  5.   

    你多了一个}:
     public  void  listen(){
            try{
                  ServerSocket  server=new  ServerSocket(listenPort);
                  Socket  incoming=null;
                  while(true){
                    incoming  =  server.accept();
              connectionhandler(incoming);
              }
              }catch(BindException  be){
                      System.out.println("Unable  to    bind  port  "+listenPort);
                  }catch(IOException  ioe){
                      System.out.println("Unable  to  instantiate  a  ServerSocket  on  port  "+listenPort);
                  }
              }//多的}
      
          }
      

  6.   

    OutputStream  outToSocket=  incoming.getOutpuStream();
    >>>>>
    OutputStream  outToSocket=  incoming.getOutputStream();
      

  7.   

    好了,谢谢 GJA106(中文字符) ,
    唉,开始我也像是这个,可是找了半天也没找见