Can not read number send with DataOutputStream

前端 未结 2 1304
时光说笑
时光说笑 2021-01-29 03:55

this is my Client code

Random rand = new Random();
int  n = rand.nextInt(50) + 1;
DataInputStream dis = new DataInputStream(_socket.getInputStream());
DataOutput         


        
2条回答
  •  忘掉有多难
    2021-01-29 04:32

    If you're using writeInt() on the write side, you should be using readInt() on the read side (all the method names correlate between DataOutputStream and DataInputStream, please read the javadoc).

提交回复
热议问题