0

我需要从包含 80 个 4 字节 int 字段的服务器接收 320 个字节的数据。如何以 4 字节接收它们并显示它们各自的 int 值?谢谢。

不确定这是否适合接收部分:

//for reading the data from the socket 

BufferedInputStream bufferinput=new BufferedInputStream(NewSocket.getInputStream());

DataInputStream datainput=new DataInputStream(bufferinput);

byte[] handsize=new byte[32];

// The control will halt at the below statement till all the 32 bytes are not read from the socket.  

datainput.readFully(handsize); 
4

1 回答 1

6
for (int i = 0; i < 80; i++) {
    System.out.println(datainput.readInt());
}
于 2010-03-21T10:27:49.917 回答