title: ByteBuffer underflow
body: <p>I try to use the java libary ByteBuffer and wrote following code example:</p>
  
  <pre><code>    ByteBuffer buf = ByteBuffer.allocate(32);
      buf.putInt(4);
      buf.putInt(8);
      buf.putInt(12);
      buf.putInt(16);
      buf.putInt(20);
      buf.putInt(24);
      buf.putInt(28);
      buf.putInt(32);
      buf.order(ByteOrder.LITTLE_ENDIAN);
      byte[] temp = new byte[32];
      buf.get(temp);
  </code></pre>
  
  <p>For some reason it throws a <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/BufferUnderflowException.html" rel="nofollow">BufferUnderflowException</a> in the last line. </p>
  
  <p>I don't know why, can somebody explain me what I am doing wrong?</p>