byte[] arr; ByteBuffer buffer = ByteBuffer.allocate(10); buffer.put((byte) 0x00); buffer.put(new byte[] {0x01, 0x02}); buffer.put(new byte[] {0x03, 0x04, 0x05}); buffer