In Java, there is no such thing as an unsigned byte.
Working with some low level code, occasionally you need to work with bytes that have unsigned values greater than 128, which causes Java to interpret them as a negative number due to the MSB being used for sign.
What’s a good way to work around this? (Saying don’t use Java is not an option)
When reading any single value from the array copy it into something like a short or an int and manually convert the negative number into the positive value it should be.
byte foobar = ..; int value = foobar; if (value < 0) value += 256 // Patch up the 'falsely' negative value
You can do a similar conversion when writing into the array.