Writes all buffered bytes to the stream and clears the buffer.

@throws \RuntimeException
357013
private function flushBuffer()
    {
        $bufferLength = $this->numberOfBytes($this->buffer);
        if ($bufferLength == 0) {
            return;
        }

        $bytesWritten = $this->decoratedObject->write($this->buffer);
        if ($bytesWritten < $bufferLength) {
            throw new \RuntimeException(
                sprintf(
                    'Expected to flush buffer of %d bytes but only %d bytes were written.',
                    $bufferLength,
                    $bytesWritten
                )
            );
        }

        $this->buffer = '';
    }
767635
public function flush()
    {
        foreach ($this->buffer as $data) {
            $this->output->write($data['messages'], $data['newline'], $data['options']);
        }

        // Clear the buffer array.
        $this->buffer = [];
    }
551353
public function write()
    {
        if (!$this->opened) {
            throw new \RuntimeException('Writer is not opened.');
        }
        $args = func_get_args();
        if (count($args) > 1) {
            $line = call_user_func_array('sprintf', $args);
        } else {
            $line = $args[0];
        }
        $lines = explode("\n", $line);
        foreach ($lines as $line) {
            if ($line) {
                $line = $this->getIndentation().$line;
            }
            $this->buffer[] = $line;
        }

        return $this;
    }
1093660
public function write($string)
    {
        if (!$this->isWritable()) {
            throw new \RuntimeException("Stream isn't writable");
        }
        
        $ret = fwrite($this->handle, $string);
        
        if ($ret === false) {
            throw new \RuntimeException("Failed to write to stream");
        }
        
        return $ret;
    }
1299078
public function write($message)
    {
        if ($this->output instanceof OutputInterface) {
            $this->output->write($message);
        } elseif (@fwrite($this->output, $message) === false) {
            throw new \RuntimeException('Unable to write output.');
        }
    }
801093
public function resetOutputStreams()
    {
        defined('STDOUT') || define('STDOUT', fopen('php://stdout', 'w'));
        defined('STDERR') || define('STDERR', fopen('php://stderr', 'w'));
        static::$streamsMap = [
            LogLevel::EMERGENCY => STDERR,
            LogLevel::ALERT => STDERR,
            LogLevel::CRITICAL => STDERR,
            LogLevel::ERROR => STDERR,
            LogLevel::WARNING => STDERR,
            LogLevel::NOTICE => STDOUT,
            LogLevel::INFO => STDOUT,
            LogLevel::DEBUG => STDOUT
        ];
    }
1347855
def flush(self):
        
        if self._writable:
            with self._seek_lock:
                self._flush_raw_or_buffered()

                # Clear the buffer
                self._write_buffer = bytearray(self._buffer_size)
                self._buffer_seek = 0
399096
public function write($string)
    {
        $result = fwrite($this->stream, $string);
        if(false === $result)
        {
            throw new \RuntimeException('write stream failed');
        }
        return $result;
    }
1249100
public function write($string) {

            if (!$this->isWritable() || ($written = fwrite($this->stream, $string)) === false) {
                throw new \RuntimeException('Could not write in a not writable stream');
            }

            return $written;

        }
933683
public function rewind()
	{
		$this->file->rewind();
		if ($this->useFirstRecordAsHeader)
		{
			if (!$this->file->valid())
			{
				throw new \RuntimeException('Expected first row to be header, but reached EOF instead');
			}
			$this->header = $this->file->current();
			$this->file->next();
		}
	}
390578
private void clear() {
        if (null != this._output) {
            for (int i = 0; i < this._output.length; i++) {
                if (null != this._output[i]) {
                    this._output[i].release();
                    this._output[i] = null;
                }
            }
        }
        this.outputIndex = 0;
        this.bufferedCount = 0;
        this.bytesWritten = 0L;
        this.setWriteListenerCallBack(null);
    }
992387
public function write($content)
    {
        if ($this->isReadable()) {
            throw new \RuntimeException("Cannot write to a readable message");
        }

        $this->writable = true;
        $content = trim($content);
        fwrite($this->resource, $content . "\n");
    }
1043267
private function writeStoredRoutineMetadata(): void
  {
    $json_data = json_encode($this->phpStratumMetadata, JSON_PRETTY_PRINT);
    if (json_last_error()!=JSON_ERROR_NONE)
    {
      throw new RuntimeException("Error of encoding to JSON: '%s'.", json_last_error_msg());
    }

    // Save the metadata.
    $this->writeTwoPhases($this->phpStratumMetadataFilename, $json_data);
  }
1298333
private function write()
    {
        $cache = serialize($this->records);
        flock($this->file, LOCK_EX);
        rewind($this->file);
        ftruncate($this->file, 0);
        $bytes = fwrite($this->file, $cache);
        flock($this->file, LOCK_UN);

        return $bytes === strlen($cache);
    }
887142
private void flushBuffer()
            throws IOException
    {
        if (buffer.position() > 0) {
            buffer.flip();
            writeCompressed(buffer);
            buffer.clear();
        }
    }
1192567
public function write($string)
    {
        $this->valideAttach()->valideWrite();
        if (($stream = fwrite($this->stream, $string)) === false) {
            throw new \RuntimeException('An error has occurred.');
        }

        return $stream;
    }
1260636
private void writeBuffer() throws IOException {
    for (int pos = 0; pos < currentBufferSize; pos++) {
      if (isByte[pos]) {
        aFile.write((byte) buffer[pos]);
      } else {
        aFile.write(buffer[pos]);
      }
    }
  }