if((str=dis.readUTF())!=null)应该是不等于-1,不是null

解决方案 »

  1.   

    改了,但是Test07.java:15: 不可比较的类型:java.lang.String 和 int
    readUTF()返回的是String类型
      

  2.   

    public final String readUTF()
                         throws IOException
    See the general contract of the readUTF method of DataInput. 
    Bytes for this operation are read from the contained input stream. 
    Specified by:
    readUTF in interface DataInput 
    Returns:
    a Unicode string. 
    Throws: 
    EOFException - if this input stream reaches the end before reading all the bytes.
     
    IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs. 
    UTFDataFormatException - if the bytes do not represent a valid modified UTF-8 encoding of a string.
    See Also:
    readUTF(java.io.DataInput)
    这问题确实很蛋疼,貌似是个bug,不建议用readutf这个方法
      

  3.   

    如果要想使用这个readUTF方法的话,有什么方法让客户端退出呢??
      

  4.   

    EOFException - if this input stream reaches the end before reading all the bytes. 这个的意思是如果到输入流的末尾的范围就会报此异常么??