public function flush()
    {
        if ($this->isOpen() === true) {
            $this->setBinary('');
            $this->rewind();
        } else {
            $msg = "Cannot flush a closed MemoryStream.";
            throw new MemoryStreamException($msg, $this, MemoryStreamException::NOT_OPEN);
        }
    }