code: public final int getNewBufferSize(int curSize, int minNewSize) {
        if (curSize <= maxDoublingSize)
           return Math.max(curSize << 1, minNewSize);
        else
           return Math.max(curSize + (curSize >> 2), minNewSize);
     }
docs: Gets the number of bytes to which the internal buffer should be resized.
  
  @param curSize    the current number of bytes
  @param minNewSize the minimum number of bytes required
  @return the size to which the internal buffer should be resized