title: Java Bytebuffer Filling up completely
body: <p>I am currently using the Java ByteBuffer</p>
  
  <pre><code>    ByteBuffer batch = ByteBuffer.allocate(tuple_size * batch_size ) ;
      int pos = 0;
      int sent = 0;
      while ( sent++ &lt; batch_size) {
              Event event = (Event) it.next();
              batch.put(event.getData(), pos, tuple_size);
              pos += tuple_size;
  
          }
      return batch.array();
  </code></pre>
  
  <p>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: </p>
  
  <pre><code>       System.out.println(pos + " " +  batch.capacity() +  " " + batch.position() + " " +  batch.remaining()); 
  </code></pre>
  
  <p>I get: 
  0   200 0   200  (round 0)</p>
  
  <p>100 200 100 100  (round 1)</p>
  
  <p>which is what one would expect. Now, based on the documentation, it seems that the bound checks do hold:</p>
  
  <pre><code> 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
  </code></pre>
  
  <p>How do I completely fill up the buffer? (whilst keeping the underlying buffer to have length tuple_size * batch_size?)</p>