![](/img/trans.png)
[英]Is it possible to decode bytes on a server which were sent from a client as a byte array?
[英]How do I receive byte array sent from a server and read 4 single bytes at a time
我需要从包含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);
for (int i = 0; i < 80; i++) {
System.out.println(datainput.readInt());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.