我尝试向服务器发送一个整数。这是我的客户代码
out = new PrintWriter(_socket.getOutputStream(), true);
Random rand = new Random();
int n = rand.nextInt(50) + 1;
out.println(n);
但是服务器怎么读呢?
答案 0 :(得分:1)
使用DataOutputStream.writeInt()/ DataInputStream.readInt()对。