title: Unable to put bytes to DirectByteBuffer in scala
body: <p>I recently encountered an issue using DirectByteBuffer in scala code. Below is my code.</p>
  <pre><code>def byteBuffer = ByteBuffer.allocateDirect(10 * 4)
  
      for (i &lt;- 0 until 10) {
        println(s&quot;Remaining: ${byteBuffer.remaining()}&quot;) // Always return 40
        byteBuffer.putFloat(1) // Also tried byteBuffer.putFloat(i, 1) to try to put it to specific index, still nothing changed.
      }
  
      byteBuffer.position(0) // With or without this line, result doesn't change
  
      for (i &lt;- 0 until 40) {
        println(s&quot;At index=$i, get=${byteBuffer.get()}&quot;) // Always 0
        println(byteBuffer.remaining()) // Always 40
      }
  </code></pre>
  <p>For the entire loop, byteBuffer.remaining() always returns 40, which seem like the &quot;put()&quot; calls never worked. As a result, the content when doing &quot;get()&quot;, content of the buffer is always 0.</p>
  <p>Even get() call does not move the index at all.</p>
  <p>Was wondering the reason why it is not writing to the directBuffer?</p>
  <p>When using HeapBuffer, the usage would generate the correct behavior, just not DirectBuffer.</p>