这是一个创建于 2208 天前的主题,其中的信息可能已经有所发展或是发生改变。
public static byte[] marshallInt(int num,int length) {
byte[] byteStream = new byte[length];
for (int i = 0; i < length; i++) {
byteStream[i] = (byte) (num >>> ((length-1)*8 - i * 8));
}
return byteStream;
}
byte length[]=marshallInt(sendmsg.length(),2);
ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
baos1.write(length);
baos1.write(sendmsg.getBytes());
byte[] bufferOut = baos1.toByteArray();
socketOut.write(bufferOut);
Python 的字节数组要怎么整 环境是 Python2.7
能力有限 搜了一圈 都没有想明白要怎么转换