BluetoothBytesParser { public static byte[] mergeArrays(byte[]... arrays) { int size = 0; for (byte[] array : arrays) { size += array.length; } byte[] merged = new byte[size]; int index = 0; for (byte[] array : arrays) { System.arraycopy(array, 0, merged, index, array.length); index += array.length; } return merged; } BluetoothBytesParser();  BluetoothBytesParser(ByteOrder byteOrder);  BluetoothBytesParser(byte[] value);  BluetoothBytesParser(byte[] value, ByteOrder byteOrder);  BluetoothBytesParser(byte[] value, int offset);  BluetoothBytesParser(byte[] value, int offset, ByteOrder byteOrder); Integer getIntValue(int formatType); Integer getIntValue(int formatType, ByteOrder byteOrder); long getLongValue(); long getLongValue(ByteOrder byteOrder); long getLongValue(int offset, ByteOrder byteOrder); Integer getIntValue(int formatType, int offset, ByteOrder byteOrder); Float getFloatValue(int formatType); Float getFloatValue(int formatType, ByteOrder byteOrder); Float getFloatValue(int formatType, int offset, ByteOrder byteOrder); String getStringValue(); String getStringValue(int offset); Date getDateTime(); Date getDateTime(int offset); byte[] getValue(); boolean setIntValue(int value, int formatType, int offset); boolean setIntValue(int value, int formatType); boolean setLong(long value); boolean setLong(long value, int offset); boolean setFloatValue(int mantissa, int exponent, int formatType, int offset); boolean setFloatValue(float value, int precision); boolean setString(String value); boolean setString(String value, int offset); void setValue(byte[] value); boolean setCurrentTime(Calendar calendar); boolean setDateTime(Calendar calendar); static String bytes2String(final byte[] bytes); static byte[] mergeArrays(byte[]... arrays); int getOffset(); void setOffset(int offset); ByteOrder getByteOrder(); @Override String toString(); static final int FORMAT_UINT8; static final int FORMAT_UINT16; static final int FORMAT_UINT32; static final int FORMAT_SINT8; static final int FORMAT_SINT16; static final int FORMAT_SINT32; static final int FORMAT_SFLOAT; static final int FORMAT_FLOAT; }
@Test public void mergeArraysTest() { byte[] array1 = new byte[]{1,2,3}; byte[] array2 = new byte[]{4,5,6}; byte[] mergedArrays = BluetoothBytesParser.mergeArrays(array1, array2); assertEquals(6, mergedArrays.length); assertEquals(array1[0], mergedArrays[0]); assertEquals(array1[1], mergedArrays[1]); assertEquals(array1[2], mergedArrays[2]); assertEquals(array2[0], mergedArrays[3]); assertEquals(array2[1], mergedArrays[4]); assertEquals(array2[2], mergedArrays[5]); }