waterml/src/main/java/ucar/nc2/ogc/erddap/util/ErddapStringArray.java
public void ensureCapacity(long minCapacity) {
        if (array.length < minCapacity) {
            //ensure minCapacity is < Integer.MAX_VALUE
            ErddapMath2.ensureArraySizeOkay(minCapacity, "StringArray");

            //caller may know exact number needed, so don't double above 2x current size
            int newCapacity = (int)Math.min(Integer.MAX_VALUE - 1, array.length + (long)array.length); 
            if (newCapacity < minCapacity) 
                newCapacity = (int)minCapacity; //safe since checked above

            String[] newArray = new String[newCapacity];
            System.arraycopy(array, 0, newArray, 0, size);
            array = newArray; //do last to minimize concurrency problems
        }
    }
public void ensureCapacity(long minCapacity) {
        if (array.length < minCapacity) {
            //ensure minCapacity is < Integer.MAX_VALUE
            ErddapMath2.ensureArraySizeOkay(minCapacity, "StringArray");

            //caller may know exact number needed, so don't double above 2x current size
            int newCapacity = (int)Math.min(Integer.MAX_VALUE - 1, array.length + (long)array.length); 
            if (newCapacity < minCapacity) 
                newCapacity = (int)minCapacity; //safe since checked above

            String[] newArray = new String[newCapacity];
            System.arraycopy(array, 0, newArray, 0, size);
            array = newArray; //do last to minimize concurrency problems
        }
    }
public void ensureCapacity ( long minCapacity ) { if ( array . length < minCapacity ) { //ensure minCapacity is < Integer.MAX_VALUE ErddapMath2 . ensureArraySizeOkay ( minCapacity , "StringArray" ) ; //caller may know exact number needed, so don't double above 2x current size int newCapacity = ( int ) Math . min ( Integer . MAX_VALUE - 1 , array . length + ( long ) array . length ) ; if ( newCapacity < minCapacity ) newCapacity = ( int ) minCapacity ; //safe since checked above String [ ] newArray = new String [ newCapacity ] ; System . arraycopy ( array , 0 , newArray , 0 , size ) ; array = newArray ; //do last to minimize concurrency problems } }
This ensures that the capacity is at least 'minCapacity'.

@param minCapacity the minimum acceptable capacity.
minCapacity is type long, but &gt;= Integer.MAX_VALUE will throw exception.
This ensures that the capacity is at least minCapacity .