code: private void ensureCapacity(int requestedCapacity) {
  
          if (requestedCapacity > getCapacity()) {
              int newCapacity = getCapacity();
              while (requestedCapacity > newCapacity) {
                  newCapacity = (newCapacity * 3) / 2;
              }
              reallocateBuffer(newCapacity);
          }
      }
docs: Make sure that the internal byte buffer can store at least requestedCapacity of bytes
  by reallocating it if necessary.<p>
  
  @param requestedCapacity the requested capacity