I\'m converting a byte array into int
by doing this:
ByteArrayInputStream bais = new ByteArrayInputStream (data);
DataInputStream dis = new Data
An int
is always a signed, 32-bit number in Java. However, this only matters if you are doing math with it. If all you care about is the pattern of 0 and 1 bits, simply ignore the sign.
If you do need to do some math, convert it to a long
by masking:
long l = j & 0xFFFFFFFFL;
Do all arithmetic with long
operands, modulo 0xFFFFFFFFL. When you are done, cast the result back to an int
and transmit it.