The first 3 bytes of a byte array are just integers, is there a better way to convert them? So far I have this but it just feels like a bad way of doing it.
public int parse_code(byte[] bs) {
char[] array = new char[3];
for(int i = 0; i < 3; i++) {
array[i] = (char) bs[i];
}
// Dirty way of doing it
return Integer.parseInt(new String(array));
}
If you know that there will always be 3 decimal digits at the beginning of the byte array you can just convert them into a integer directly: