Java与C#通信之byte[]转short问题
public short getMsgByteLen(DataInputStream dis) {
byte[] lens = new byte[2];
try{
dis.read(lens);
} catch(IOException e) {
e.printStackTrace();
}
//如果是和java通信
return (short)((lens[0] << 8) + lens[1]);
//如果是和C#通信
return (short)((lens[1] << 8) + lens[0]);
}

浙公网安备 33010602011771号