I read byte[] from socket as Param_Code which includes ID.
byte[] cbuf = new byte[4];
socketReader.read(cbuf, 0, 4);
int Param_Code = byteArrayToIntBI(cbuf, 0);
public static int byteArrayToIntBI(byte[] b, int offset) {
int value = 0;
for (int i = 3; i > -1; i--) {
int shift = (i) * 8;
value += (b[i + offset] & 0x000000FF) << shift;
}
return value;
}
• Option 1: Sometimes the Param_code corresponds only to the ID
• Option 2: Sometimes the Param_code corresponds to 0x40000000 + the ID
• Option 3: Sometimes the Param_code corresponds to 0x80000000 + the ID
My question is, How can i get ID from Param_code considering above options.
How about using ByteBuffer?