code: private void prepareForWrite(long pos, long len) throws IOException {
      long end = pos + len;
  
      // allocate any additional blocks needed
      int lastBlockIndex = blockCount - 1;
      int endBlockIndex = blockIndex(end - 1);
  
      if (endBlockIndex > lastBlockIndex) {
        int additionalBlocksNeeded = endBlockIndex - lastBlockIndex;
        disk.allocate(this, additionalBlocksNeeded);
      }
  
      // zero bytes between current size and pos
      if (pos > size) {
        long remaining = pos - size;
  
        int blockIndex = blockIndex(size);
        byte[] block = blocks[blockIndex];
        int off = offsetInBlock(size);
  
        remaining -= zero(block, off, length(off, remaining));
  
        while (remaining > 0) {
          block = blocks[++blockIndex];
  
          remaining -= zero(block, 0, length(remaining));
        }
  
        size = pos;
      }
    }
docs: Prepares for a write of len bytes starting at position pos.