code: public void ensureCapacity(int n)
          throws IOException
      {
          // Do we have space?
          if (n>capacity())
          {
              // Make a bigger buffer if we are allowed.
              if (_fixed)
                  throw new IllegalStateException("Fixed");
                  
              int new_size = ((n+_preReserve+_postReserve+4095)/4096)*4096;
              
              byte[] old = _buf;
              _buf = new byte[new_size];
              if (_pos>_start)
                  System.arraycopy(old,_start,_buf,_start,_pos-_start);
              if (!_resized)
                  ByteArrayPool.returnByteArray(old);
                  
              _end=_buf.length-_postReserve;
              _resized=true;
          }
      }
docs: /* ------------------------------------------------------------