发送一个数字与套接字
问题描述:
我试图发送一个整数到服务器。这是我的客户代码发送一个数字与套接字
out = new PrintWriter(_socket.getOutputStream(), true);
Random rand = new Random();
int n = rand.nextInt(50) + 1;
out.println(n);
但是服务器如何读取它?
答
改为使用DataOutputStream.writeInt()/ DataInputStream.readInt()对。
他的''''InputStream'。 – 2013-04-30 15:05:47