code: public static byte[] ensureCapacity(byte[] array, int minCapacity) {
  	int oldCapacity = array.length;
  	byte[] newArray;
  	if (minCapacity > oldCapacity) {
  	    int newCapacity = (oldCapacity * 3)/2 + 1;
  		if (newCapacity < minCapacity) {
  			newCapacity = minCapacity;
  		}
  		
  	    newArray = new byte[newCapacity];
  	    System.arraycopy(array, 0, newArray, 0, oldCapacity);
  	}
  	else {
  		newArray=array;
  	}
  	return newArray;
  }
docs: Ensures that a given array can hold up to <tt>minCapacity</tt> elements.
  
  Returns the identical array if it can hold at least the number of elements specified.
  Otherwise, returns a new array with increased capacity containing the same elements, ensuring
  that it can hold at least the number of elements specified by
  the minimum capacity argument.
  
  @param   minCapacity   the desired minimum capacity.