public void resize(int size){
  if (buffer != null) {
    if (size >= 0 && size < buffer.size()) {
      int oldLastIndex=buffer.size() - 1;
      int newLastIndex=size - 1;
      for (int i=oldLastIndex; i > newLastIndex; i--) {
        buffer.remove(i);
      }
    }
  }
 else {
    if (size >= 0 && size < offsets.size()) {
      long offset=offsets.get(size);
      byteCache.resize(key,offset);
      ArrayList<Long> newOffsets=new ArrayList<Long>(size);
      for (int i=0; i < size; i++) {
        newOffsets.add(offsets.get(i));
      }
      offsets=newOffsets;
    }
  }
}

public void resize ( int size ) { if ( buffer != null ) { if ( size >= 0 && size < buffer . size ( ) ) { int oldLastIndex = buffer . size ( ) - 1 ; int newLastIndex = size - 1 ; for ( int i = oldLastIndex ; i > newLastIndex ; i -- ) { buffer . remove ( i ) ; } } } else { if ( size >= 0 && size < offsets . size ( ) ) { long offset = offsets . get ( size ) ; byteCache . resize ( key , offset ) ; ArrayList < Long > newOffsets = new ArrayList < Long > ( size ) ; for ( int i = 0 ; i < size ; i ++ ) { newOffsets . add ( offsets . get ( i ) ) ; } offsets = newOffsets ; } } }
resizes the array to contain a smaller number of elements . has no effect if the size is greater than current number of elements .
