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)
for (int i = 0; i < 80; i++) {
System.out.println(datainput.readInt());
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
197 次 |
| 最近记录: |