private void expandBuffer ( int newBufferSize ) { // Allocate a new buffer. ByteBuffer newBuffer = ByteBuffer . allocate ( newBufferSize ) ; // Copy the content of the current buffer to the new buffer. int oldPosition = mBuffer . position ( ) ; mBuffer . position ( 0 ) ; newBuffer . put ( mBuffer ) ; newBuffer . position ( oldPosition ) ; // Replace the buffers. mBuffer = newBuffer ; }
Expand the size of the internal buffer .