private void pad(long pos) throws IOException {
  long currIndex=cacheStart + cache.size() - 1;
  long lastIndex=pos / BUFFER_LENGTH;
  long numNewBuffers=lastIndex - currIndex;
  for (long i=0; i < numNewBuffers; i++) {
    try {
      cache.add(new byte[BUFFER_LENGTH]);
    }
 catch (    OutOfMemoryError e) {
      throw new IOException("No memory left for cache!");
    }
  }
}

private void pad ( long pos ) throws IOException { long currIndex = cacheStart + cache . size ( ) - 1 ; long lastIndex = pos / BUFFER_LENGTH ; long numNewBuffers = lastIndex - currIndex ; for ( long i = 0 ; i < numNewBuffers ; i ++ ) { try { cache . add ( new byte [ BUFFER_LENGTH ] ) ; } catch ( OutOfMemoryError e ) { throw new IOException ( "No memory left for cache!" ) ; } } }
ensure that there is space to write a byte at the given position .
