我想選擇字節數組中最後一個字節的低4位。這是我以前在PHP中完成的,但我是Java新手。Java字節數組操作
$lower4bit = substr($bytes[19], -1);
//Convert the hex to decimal to get the offset value
$offset = hexdec($lower4bit);
//Select the value of the 4 bytes starting at the offset
$joinedArray = implode(array_slice($bytes, $offset, 4));
任何人都可以用Java指出正確的方向嗎?
我沒有時間得到完整的答案,但請記住......在PHP中,「數組」是數組,列表,地圖和其他所有東西。在Java中,它們並不是全部合而爲一。 – corsiKa
即使在PHP中,這也是非常錯誤的做法。 '$ lower4bit = $ bytes [19] & 0x0F;' – Esailija