Write output data in file system
@param  {String} filename Output file name
@param  {Array}  content  List of contents
@return {String}          Stringified list of contents
552295
function write (filename, content) {
  const json = JSON.stringify(content, (key, value) => value === undefined ? null : value)
  fs.writeFileSync(filename, json)
  return json
}
1236567
protected void writeFile(String basename, T content,
			Function2<? super File, ? super String, ? extends File> outputDirectoryFilter) {
		// Create the file.
		// Encode
		final byte[] bytes = content.toString().getBytes(Charset.forName(getCodeConfig().getEncoding()));
		writeFile(basename, bytes, outputDirectoryFilter);
	}
704530
def write(content, filename='cache'):
	
	cache_path = get_cache_path(filename)
	with open(cache_path, 'w') as file:
		if content is not None:
			json.dump(content, file, indent=3, sort_keys=True)
797325
private function write($src, $fileName, $content)
    {

        if (!$this->file->exists($src)) {
            $this->file->makeDirectory($src);
        }
        $this->file->put($fileName, $content);
    }
232367
def write_file_lines(self, filename, contents):
        
        with open(filename, 'wb') as f:
            self.log.debug(contents)
            f.writelines(contents)
1277665
public static void writeOutContent(final byte[] data, final String filename, final String mime) {
        writeOutContent(data, filename, mime, true);
    }
1064413
def write_file(self, filename, content):
        
        with open(filename, 'wb') as f:
            self.log.debug(content)
            f.write(content)
854307
def write(self, content=None):
        
        if self.system.files.no_output is True:
            return

        t, _ = elapsed()

        if not content:
            logger.warning('report content not specified.')
            return

        self.update(content)

        system = self.system
        file = system.files.output
        export = all_formats.get(system.config.export, 'txt')
        module = importlib.import_module('andes.formats.' + export)
        dump_data = getattr(module, 'dump_data')

        text = list()
        header = list()
        rowname = list()
        data = list()

        text.append(self.info)
        header.append(None)
        rowname.append(None)
        data.append(None)

        if content == 'summary' or 'extended' or 'powerflow':
            text.append(['SUMMARY:\n'])
            header.append(None)
            rowname.append(self._basic_name)
            data.append([self.basic[item] for item in self._basic])

        if content == 'extended' or 'powerflow':
            text.append(['EXTENDED SUMMARY:\n'])
            header.append(['P (pu)', 'Q (pu)'])
            rowname.append(
                ['Generation', 'Load', 'Shunt Inj', 'Losses', 'Line Charging'])
            Pcol = [
                self.extended['Pg'],
                self.extended['Pl'],
                self.extended['Psh'],
                self.extended['Ploss'],
                self.extended['Pch'],
            ]

            Qcol = [
                self.extended['Qg'],
                self.extended['Ql'],
                self.extended['Qsh'],
                self.extended['Qloss'],
                self.extended['Qch'],
            ]

            data.append([Pcol, Qcol])

        if content == 'powerflow' and system.pflow.solved:
            idx, name, Vm, Va, Pg, Qg, Pl, Ql = system.get_busdata()
            Va_unit = 'deg' if system.pflow.config.usedegree else 'rad'
            text.append(['BUS DATA:\n'])
            # todo: consider system.pflow.config.units
            header.append([
                'Vm(pu)', 'Va({:s})'.format(Va_unit), 'Pg (pu)', 'Qg (pu)',
                'Pl (pu)', 'Ql (pu)'
            ])
            name = [str(i) + '-' + j[:8] for i, j in zip(idx, name)]
            rowname.append(name)
            data.append([Vm, Va, Pg, Qg, Pl, Ql])

            # Node data
            if hasattr(system, 'Node') and system.Node.n:
                idx, name, V = system.get_nodedata()
                text.append(['NODE DATA:\n'])
                header.append(['V(pu)'])
                rowname.append(name)
                data.append([V])

            # Line data
            name, fr, to, Pfr, Qfr, Pto, Qto, Ploss, Qloss = \
                system.get_linedata()
            text.append(['LINE DATA:\n'])
            header.append([
                'From Bus', 'To Bus', 'P From (pu)', 'Q From (pu)',
                'P To (pu)', 'Q To(pu)', 'P Loss(pu)', 'Q Loss(pu)'
            ])
            rowname.append(name)
            data.append([fr, to, Pfr, Qfr, Pto, Qto, Ploss, Qloss])

            # Additional Algebraic data
            text.append(['OTHER ALGEBRAIC VARIABLES:\n'])
            header.append([''])
            rowname.append(
                system.varname.unamey[2 * system.Bus.n:system.dae.m])
            data.append([round(i, 5) for i in system.dae.y[2 * system.Bus.n:]])

            # Additional State variable data
            if system.dae.n:
                text.append(['OTHER STATE VARIABLES:\n'])
                header.append([''])
                rowname.append(system.varname.unamex[:])
                data.append([round(i, 5) for i in system.dae.x[:]])

        dump_data(text, header, rowname, data, file)

        _, s = elapsed(t)
        logger.info('report written to <{:s}> in {:s}.'.format(system.files.output, s))
106359
public void stringToFile(String content, String filename) throws IOException {
        stringToOutputStream(content, new FileOutputStream(filename));
    }
221795
def write_json(filename, content):
    '''
    
    '''

    j = _dumps(content, indent=4, sort_keys=True)
    if j:
        return write_file(filename, j)
819096
public static File writeFile(String filename, String content) {
        PrintWriter pw = null;
        try {
            pw = new PrintWriter(filename, FILE_ENCODING);
            pw.write(content);
            pw.flush();
        } catch (FileNotFoundException e) {
            throw new IllegalArgumentException("Unable to write to: " + filename, e);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        } finally {
            if (pw != null) {
                pw.close();
            }
        }
        return new File(filename);
    }
755245
def write_to_output(content, output=None,
                    encoding=anytemplate.compat.ENCODING):
    
    if anytemplate.compat.IS_PYTHON_3 and isinstance(content, bytes):
        content = str(content, encoding)

    if output and not output == '-':
        _write_to_filepath(content, output)
    elif anytemplate.compat.IS_PYTHON_3:
        print(content)
    else:
        print(content.encode(encoding.lower()), file=get_output_stream())
452900
public function write($name, $content)
    {
        $name = $this->getRealName($name);
        $directory = sprintf('%s%s', $this->buildDirectory, substr($name, 0, strrpos($name, '/')));
        $name = substr($name, strrpos($name, '/'));

        if (false === file_exists($directory)) {
            $this->filesystem->mkdir($directory);
        }

        file_put_contents(sprintf('%s/%s', $directory, $name), $content);
    }
1243718
def writeFile(filename, content, encoding=None):
    """"""
    if not content:
        raise OSError("empty content for file %s" % filename)

    def getfp(filename, encoding):
        """Get open file object."""
        if encoding:
            return codecs.open(filename, 'w', encoding)
        return open(filename, 'wb')

    try:
        with getfp(filename, encoding) as fp:
            fp.write(content)
            fp.flush()
            os.fsync(fp.fileno())
            size = os.path.getsize(filename)
            if size == 0:
                raise OSError("empty file %s" % filename)
    except Exception:
        if os.path.isfile(filename):
            os.remove(filename)
        raise
    else:
        out.info(u"Saved %s (%s)." % (filename, strsize(size)))
133408
def write_file(filename, content):
    '''
    
    '''

    if filename and _path.exists(_path.dirname(filename)) and content:
        with open(filename, 'w') as f:
            return f.write(content)
352720
function (content) {
      var fileContent = self._readFileSync();

      fileContent.instances = fileContent.instances || {};
      fileContent.instances[this._id] = content;
      self._writeFileSync(fileContent);
    }
961633
public void stringToFile(String content, File file) throws IOException {
        stringToOutputStream(content, new FileOutputStream(file));
    }