views:

170

answers:

1

In Java, I can't take a byte array of unsigned bytes (from something such as Wire Shark) and put this into java.... Because I will get compile errors since anything greater than 127 decimal/0x07F is treated not as a byte, but as an int.... IE:

        byte[] protocol = { 0x04, 0x01, 0x00, 0x50, /*error*/0xc1, /*error*/0xdb, 0x1c, /*error*/0x8c, 
                0x4d, 0x4f, 0x5a, 0x00 };

Need a good way to handle taking unsigned char arrays and putting them into Java as literals.

+5  A: 

Cast them to (byte).

PSpeed
Heh, it's late. For some reason I had came up with casting them first to (char), then to (byte). Also, noteworthy for non-java'ers: char is 16bit unicode word in Java.
Zombies
It's funny the paths that the sleep-deprived mind will take us down. :)
PSpeed