如何接收从服务器发送的字节数组,一次读取4个单字节

0 java sockets bufferedinputstream

我需要从服务器接收320字节的数据,该服务器包含80个4字节的int字段.我如何以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); 
Run Code Online (Sandbox Code Playgroud)

som*_*guy 6

for (int i = 0; i < 80; i++) {
    System.out.println(datainput.readInt());
}
Run Code Online (Sandbox Code Playgroud)