The code is giving me the correct int output now. Thank you so much for walking me through this. My Arduino sketch is coded like this:
union{
int i;
byte b[2];
}u;
u.i = accel;
Serial.write(u.b, 2);
My java code for reading the byte array and converting it to an int looks like this:
int n = 2;
byte[] chunk = new byte[n];
input.read(chunk);
short value = 0;
// get 2 bytes, unsigned 0..255
int low = chunk[0] & 0xff;
int high = chunk[1] & 0xff;
value = (short) (high << 8 | low) ;
System.out.println(value);
I am working on converting a 4 byte array to a float, but this is proving tricky. If I find a bit shifting technique that works for floats I will post it. Thanks again for your help.