@Test public void threeBytesToInt_buffer_ok_1() { int value = ByteArrayUtil.threeBytesToInt(BYTEARRAY_LEN_3, 0); assertThat(value).isEqualTo(0x123456); }
public static int threeBytesToInt(byte[] bytes, int offset) { if (bytes == null || bytes.length < offset + 3 || offset < 0) { throw new IllegalArgumentException("Bad data for converting 3-byte integers."); } return (bytes[offset] & 0xFF) << 16 | (bytes[offset + 1] & 0xFF) << 8 | (bytes[offset + 2] & 0xFF); }
ByteArrayUtil { public static int threeBytesToInt(byte[] bytes, int offset) { if (bytes == null || bytes.length < offset + 3 || offset < 0) { throw new IllegalArgumentException("Bad data for converting 3-byte integers."); } return (bytes[offset] & 0xFF) << 16 | (bytes[offset + 1] & 0xFF) << 8 | (bytes[offset + 2] & 0xFF); } }
ByteArrayUtil { public static int threeBytesToInt(byte[] bytes, int offset) { if (bytes == null || bytes.length < offset + 3 || offset < 0) { throw new IllegalArgumentException("Bad data for converting 3-byte integers."); } return (bytes[offset] & 0xFF) << 16 | (bytes[offset + 1] & 0xFF) << 8 | (bytes[offset + 2] & 0xFF); } private  ByteArrayUtil(); }
ByteArrayUtil { public static int threeBytesToInt(byte[] bytes, int offset) { if (bytes == null || bytes.length < offset + 3 || offset < 0) { throw new IllegalArgumentException("Bad data for converting 3-byte integers."); } return (bytes[offset] & 0xFF) << 16 | (bytes[offset + 1] & 0xFF) << 8 | (bytes[offset + 2] & 0xFF); } private  ByteArrayUtil(); static byte[] fromHex(String hex); static String toHex(byte[] byteArray); static int twoBytesToInt(byte[] bytes, int offset); static int twoBytesSignedToInt(byte[] bytes, int offset); static int threeBytesToInt(byte[] bytes, int offset); static int threeBytesSignedToInt(byte[] bytes, int offset); static int fourBytesToInt(byte[] bytes, int offset); }
ByteArrayUtil { public static int threeBytesToInt(byte[] bytes, int offset) { if (bytes == null || bytes.length < offset + 3 || offset < 0) { throw new IllegalArgumentException("Bad data for converting 3-byte integers."); } return (bytes[offset] & 0xFF) << 16 | (bytes[offset + 1] & 0xFF) << 8 | (bytes[offset + 2] & 0xFF); } private  ByteArrayUtil(); static byte[] fromHex(String hex); static String toHex(byte[] byteArray); static int twoBytesToInt(byte[] bytes, int offset); static int twoBytesSignedToInt(byte[] bytes, int offset); static int threeBytesToInt(byte[] bytes, int offset); static int threeBytesSignedToInt(byte[] bytes, int offset); static int fourBytesToInt(byte[] bytes, int offset);  }