public ByteArray resize(ByteArray array,long size){
  if (array instanceof BigByteArray) {
    return resizeInPlace((BigByteArray)array,size);
  }
 else {
    AbstractArray arr=(AbstractArray)array;
    final ByteArray newArray=newByteArray(size,arr.clearOnResize);
    final byte[] rawArray=((ByteArrayWrapper)array).array;
    newArray.set(0,rawArray,0,(int)Math.min(rawArray.length,newArray.size()));
    arr.close();
    return newArray;
  }
}

public ByteArray resize ( ByteArray array , long size ) { if ( array instanceof BigByteArray ) { return resizeInPlace ( ( BigByteArray ) array , size ) ; } else { AbstractArray arr = ( AbstractArray ) array ; final ByteArray newArray = newByteArray ( size , arr . clearOnResize ) ; final byte [ ] rawArray = ( ( ByteArrayWrapper ) array ) . array ; newArray . set ( 0 , rawArray , 0 , ( int ) Math . min ( rawArray . length , newArray . size ( ) ) ) ; arr . close ( ) ; return newArray ; } }
resize the array to the exact provided size .
