I am currently using the Java ByteBuffer

```
    ByteBuffer batch = ByteBuffer.allocate(tuple_size * batch_size ) ;
    int pos = 0;
    int sent = 0;
    while ( sent++ < batch_size) {
            Event event = (Event) it.next();
            batch.put(event.getData(), pos, tuple_size);
            pos += tuple_size;

        }
    return batch.array();

```

Currently, batch\_size is set to 2. My issue is that on the second round, I get an IndexOutofBoundsException which I cannot explain given that, printing out the follwoing details: 

```
       System.out.println(pos + " " +  batch.capacity() +  " " + batch.position() + " " +  batch.remaining()); 

```

I get: 
0 200 0 200 (round 0)

100 200 100 100 (round 1)

which is what one would expect. Now, based on the documentation, it seems that the bound checks do hold:

```
 offset - The offset within the array of the first byte to be read; must be non-negative and no larger than array.length
 length - The number of bytes to be read from the given array; must be non-negative and no larger than array.length - offset

```

How do I completely fill up the buffer? (whilst keeping the underlying buffer to have length tuple\_size \* batch\_size?)