code: public void setLength(long size) throws IOException
     {
        if (size < 0)
        {
           throw new IOException("Size must be higher or equals 0. But given " + size);
        }
  
        if (channel.size() < size)
        {
           // extend file
           MappedByteBuffer bb = channel.map(FileChannel.MapMode.READ_WRITE, size, 0);
           bb.force();
        }
        else
        {
           // truncate file
           channel.truncate(size);
        }
     }
docs: Set length of the Value in bytes to the specified <code>size</code>.
  
  If <code>size</code> is lower 0 the IOException exception will be thrown.
  
  This operation can be used both for extend and for truncate the Value size.
  
  This method used internally in update operation in case of extending the size to the given
  position.
  
  @param size
  @throws IOException