Writes a data file.

@param  string $file The file name
@param  array  $data Data to write to the file.
@return void
330470
public function write($file, $data)
    {
        $file = '/data/' . $file;

        /**
         * @todo validate that $file is a string
         * @todo validate that $data is a string
         */

        $data = json_decode(json_encode($data), true);

        $data_content = isset($data['content']) ? $data['content'] : '';

        unset($data['content']);

        $data = '---' . PHP_EOL . trim($this->yaml->dump($data, 5)) . PHP_EOL . '---' . PHP_EOL . $data_content;

        $this->source_filesystem->createDir(dirname($file));

        $this->source_filesystem->put($file, $data);
    }
122421
public function writeToFile($filename, $data, $header = '')
    {
        $ini = $this->writeToString($data, $header);
        if (!file_put_contents($filename, $ini))
            throw new IniWritingException(sprintf('Impossible to write to file %s', $filename));
    }
98859
protected function _write($data)
    {
        $result = @fwrite($this->_fileHandler, $data);

        if (false === $result) {
            throw new Mage_Exception('Failed to write data to ' . $this->_filePath);
        }
    }
381467
protected function write(string $data):void{
		$len = \strlen($data);

		for($i = 0; $i + 1 < $len; $i += 2){
			$c = ((0xff & \ord($data[$i])) << 8) | (0xff & \ord($data[$i + 1]));

			if(0x8140 <= $c && $c <= 0x9FFC){
				$c -= 0x8140;
			}
			elseif(0xE040 <= $c && $c <= 0xEBBF){
				$c -= 0xC140;
			}
			else{
				throw new QRCodeDataException('illegal char at '.($i + 1).' ['.$c.']');
			}

			$this->bitBuffer->put((($c >> 8) & 0xff) * 0xC0 + ($c & 0xff), 13);

		}

		if($i < $len){
			throw new QRCodeDataException('illegal char at '.($i + 1));
		}

	}
349914
private function _write($file, $data, $config)
    {
        $result = file_put_contents($file, $data);
        if ($result !== false) {
            // set permissions of the new file (no execute)
            $chmod = $config->get('Cache.SerializerPermissions');
            if ($chmod !== null) {
                chmod($file, $chmod & 0666);
            }
        }
        return $result;
    }
31171
protected function assertData($data, string $file): void
    {
        if ($data === false || $data === null) {
            throw new LoadException("Failed to load settings from '$file'");
        }

        if (!$data instanceof stdClass && !is_associative_array($data)) {
            throw new LoadException("Failed to load settings from '$file': data should be key/value pairs");
        }
    }
225253
private function writeFile($path, $data)
    {
        if (false === @file_put_contents($path, $data)) {
            throw new DumperException(sprintf('Unable to write file "%s"', $path));
        }
    }
222616
public synchronized void write(File file, Collection<MLArray> data)
            throws IOException
    {
        FileOutputStream fos = new FileOutputStream(file);

        try
        {
            write(fos.getChannel(), data);
        }
        catch ( IOException e )
        {
            throw e;
        }
        finally
        {
            fos.close();
        }
    }
1260824
protected function saveCredentialJson(string $file, $data)
    {
        $content = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PARTIAL_OUTPUT_ON_ERROR | JSON_PRETTY_PRINT);
        $this->filesystem->dumpFile($file, $content);
    }
1078976
public function show($file, $data)
    {
        $this->setTemplate($file);
        //
        $this->assign($data);
        //
        $this->store($this->compile());
        //
        $this->display();
    }
167334
public static function append(string $file = '', string $data = ''): bool
    {
        return static::write($file, $data, true);
    }
1274890
protected function _fwrite($data, $length=null)
    {
        if ($length === null ) {
            fwrite($this->_fileHandle, $data);
        } else {
            fwrite($this->_fileHandle, $data, $length);
        }
    }
922456
public static void write(byte[] data, File file) {
        try {
            write(new ByteArrayInputStream(data), new BufferedOutputStream(new FileOutputStream(file)));
        } catch (FileNotFoundException e) {
            throw E.ioException(e);
        }
    }
989965
public function set($key, $data)
    {
        $file = $this->getFilePath($key);

        if ($handle = fopen($file, 'w')) {
            fwrite($handle, $data);
            fclose($handle);
        }
    }
594845
public function write(array $data): void
    {
        $this->doWrite($data, $this->file, $this->sheet, $this->range);
    }
172417
public function write(string $data): void
	{
		if ($this->connected() === false)
		{
			throw new \Exception('Not connected');
		}

		fwrite($this->connection, $data);
	}
363457
public static function saveToFile($data, $file) {
		$file = Yii::getAlias($file);
		file_put_contents($file, "<?php\nreturn " . VarDumper::export($data) . ";\n", LOCK_EX);
		self::invalidateScriptCache($file);
	}