/*
(non-Javadoc)
@see net.roboconf.doc.generator.internal.AbstractStructuredRenderer
#writeFileContent(java.lang.String)
429619
@Override
	protected File writeFileContent( String fileContent ) throws IOException {

		// Load the template
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		InputStream in = getClass().getResourceAsStream( "/html.tpl" );
		Utils.copyStreamSafely( in, out );

		// Create the target directory
		File targetFile = new File( this.outputDirectory, "index.html" );
		Utils.createDirectory( targetFile.getParentFile());

		// Deal with the CSS file
		final String css;
		final String cssReference = this.options.get( DocConstants.OPTION_HTML_CSS_REFERENCE );
		if( cssReference != null ) {
			css = cssReference.trim();

		} else {
			css = "style.css";
			writeCssFile();
		}

		// Write sections
		for( Map.Entry<String,StringBuilder> entry : this.sectionNameToContent.entrySet()) {

			int index = entry.getKey().lastIndexOf( '/' );
			String title = entry.getKey().substring( index + 1 );
			String toWrite = out.toString( "UTF-8" )
					.replace( TITLE_MARKUP, title )
					.replace( CONTENT_MARKUP, entry.getValue().toString())
					.replace( MENU_MARKUP, this.menu )
					.replace( "href=\"", "href=\"../" )
					.replace( "src=\"", "src=\"../" )
					.replaceAll( "\n{3,}", "\n\n" );

			if( cssReference != null )
				toWrite = toWrite.replace( "../" + CSS_MARKUP, css );
			else
				toWrite = toWrite.replace( CSS_MARKUP, css );

			File sectionFile = new File( this.outputDirectory, entry.getKey() + ".html" );
			Utils.createDirectory( sectionFile.getParentFile());
			Utils.writeStringInto( toWrite, sectionFile );
		}

		// Write the main file
		String toWrite = out.toString( "UTF-8" )
				.replace( TITLE_MARKUP, this.applicationTemplate.getName())
				.replace( CSS_MARKUP, css )
				.replace( CONTENT_MARKUP, fileContent )
				.replace( MENU_MARKUP, this.menu )
				.replaceAll( "\n{3,}", "\n\n" );

		Utils.writeStringInto( toWrite, targetFile );

		// And the header image
		String imagePath = this.options.get( DocConstants.OPTION_HTML_HEADER_IMAGE_FILE );
		try {
			File sourceFile = null;
			if( imagePath != null )
				sourceFile = new File( imagePath );

			if( sourceFile != null && sourceFile.exists())
				in = new FileInputStream( sourceFile );
			else
				in = getClass().getResourceAsStream( "/roboconf.jpg" );

			File imgFile = new File( this.outputDirectory, "header.jpg" );
			Utils.copyStream( in, imgFile );

		} finally {
			Utils.closeQuietly( in );
		}

		return targetFile;
	}
1039985
public void writeContent(final OutputStream result) throws IOException
    {
    	for(int i = 0; i < this.tabs.size(); i++) {
    		RtfTab rt = (RtfTab) this.tabs.get(i);
    		rt.writeContent(result);
    	}
    }
1248737
private boolean writeContent(CmsObject cmsObject, I_CmsReport report, CmsFile file, byte[] content) {

        boolean success = true;

        // get current lock from file
        try {
            // try to lock the resource
            if (!lockResource(cmsObject, file, report)) {
                report.println(
                    Messages.get().container(Messages.RPT_SOURCESEARCH_LOCKED_FILE_0, cmsObject.getSitePath(file)),
                    I_CmsReport.FORMAT_ERROR);
                success = false;
            }
        } catch (CmsException e) {
            report.println(
                Messages.get().container(Messages.RPT_SOURCESEARCH_LOCKED_FILE_0, cmsObject.getSitePath(file)),
                I_CmsReport.FORMAT_ERROR);
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getMessageContainer(), e);
            }
            success = false;
        }

        // write the file content
        try {
            file.setContents(content);
            cmsObject.writeFile(file);
        } catch (Exception e) {
            m_errorUpdate += 1;
            report.println(
                org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_FAILED_0),
                I_CmsReport.FORMAT_ERROR);
            if (LOG.isErrorEnabled()) {
                LOG.error(e.toString());
            }
            success = false;
        }

        // unlock the resource
        try {
            cmsObject.unlockResource(cmsObject.getSitePath(file));
        } catch (CmsException e) {
            m_errorUpdate += 1;
            report.println(
                Messages.get().container(Messages.RPT_SOURCESEARCH_UNLOCK_FILE_0),
                I_CmsReport.FORMAT_WARNING);
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getMessageContainer(), e);
            }
            success = false;
        }

        if (success) {
            // successfully updated
            report.println(
                org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
                I_CmsReport.FORMAT_OK);
        }

        return success;
    }
932745
public void setFileContents(final String key, final byte[] contents) {
		MockFileItem fileItem = new MockFileItem();
		fileItem.set(contents);
		files.put(key, new FileItem[]{fileItem});
	}
166872
public void setSourceContent(String aSourceFile, String aSourceContent) {
        String source = aSourceFile;
        if (this._sourceRoot != null) {
            source = Util.relative(this._sourceRoot, source);
        }

        if (aSourceContent != null) {
            // Add the source content to the _sourcesContents map.
            // Create a new _sourcesContents map if the property is null.
            if (this._sourcesContents == null) {
                this._sourcesContents = new HashMap<>();
            }
            this._sourcesContents.put(source, aSourceContent);
        } else if (this._sourcesContents != null) {
            // Remove the source file from the _sourcesContents map.
            // If the _sourcesContents map is empty, set the property to null.
            this._sourcesContents.remove(source);
            if (this._sourcesContents.isEmpty()) {
                this._sourcesContents = null;
            }
        }
    }
1209171
@Override
	public void writeHeader(OutputStream os) throws IOException {	
		os.write(ascii("Content-Disposition: form-data; name=\"" + enc(controlName)
				 + "\"" +
				((fileName != null) ? "; filename=\"" + enc(fileName) + "\"" : "") + "\r\n")); 
		wrappedContent.writeHeader(os);
	}
67646
private void writeToContentChunk(final String tmpContent, final URI outputFileName, final boolean needWriteDitaTag) throws IOException {
        assert outputFileName.isAbsolute();
        logger.info("Writing " + outputFileName);
        try (OutputStreamWriter ditaFileOutput = new OutputStreamWriter(new FileOutputStream(new File(outputFileName)), StandardCharsets.UTF_8)) {
            if (outputFileName.equals(changeTable.get(outputFileName))) {
                // if the output file is newly generated file
                // write the xml header and workdir PI into new file
                writeStartDocument(ditaFileOutput);
                final URI workDir = outputFileName.resolve(".");
                if (!OS_NAME.toLowerCase().contains(OS_NAME_WINDOWS)) {
                    writeProcessingInstruction(ditaFileOutput, PI_WORKDIR_TARGET, new File(workDir).getAbsolutePath());
                } else {
                    writeProcessingInstruction(ditaFileOutput, PI_WORKDIR_TARGET, UNIX_SEPARATOR + new File(workDir).getAbsolutePath());
                }
                writeProcessingInstruction(ditaFileOutput, PI_WORKDIR_TARGET_URI, workDir.toString());

                final File path2rootmap = toFile(getRelativePath(outputFileName, job.getInputMap())).getParentFile();
                writeProcessingInstruction(ditaFileOutput, PI_PATH2ROOTMAP_TARGET_URI, path2rootmap == null ? "./" : toURI(path2rootmap).toString());

                if (conflictTable.get(outputFileName) != null) {
                    final String relativePath = getRelativeUnixPath(new File(currentFile.resolve(".")) + UNIX_SEPARATOR + FILE_NAME_STUB_DITAMAP,
                            new File(conflictTable.get(outputFileName)).getAbsolutePath());
                    String path2project = getRelativeUnixPath(relativePath);
                    if (null == path2project) {
                        path2project = "";
                    }
                    writeProcessingInstruction(ditaFileOutput, PI_PATH2PROJ_TARGET, path2project);
                    writeProcessingInstruction(ditaFileOutput, PI_PATH2PROJ_TARGET_URI, path2project.isEmpty() ? "./" : toURI(path2project).toString());
                }
            }
            if (needWriteDitaTag) {
                final AttributesImpl atts = new AttributesImpl();
                addOrSetAttribute(atts, ATTRIBUTE_NAMESPACE_PREFIX_DITAARCHVERSION, DITA_NAMESPACE);
                addOrSetAttribute(atts, ATTRIBUTE_PREFIX_DITAARCHVERSION + COLON + ATTRIBUTE_NAME_DITAARCHVERSION, "1.3");
                writeStartElement(ditaFileOutput, ELEMENT_NAME_DITA, atts);
            }
            // write the final result to the output file
            ditaFileOutput.write(tmpContent);
            if (needWriteDitaTag) {
                writeEndElement(ditaFileOutput, ELEMENT_NAME_DITA);
            }
            ditaFileOutput.flush();
        } catch (SAXException e) {
            throw new IOException(e);
        }
    }
488425
public static boolean writeString(String filePath, String content, boolean append) throws IOException {
        return writeString(filePath != null ? new File(filePath) : null, content, append);
    }
762478
static function writeFile( $filename,  $fileContent,  $flags=null){
        mkdir(dirname($filename), 0777, true);
        file_put_contents($filename,$fileContent,$flags);
    }
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);
	}
106359
public void stringToFile(String content, String filename) throws IOException {
        stringToOutputStream(content, new FileOutputStream(filename));
    }
461328
public File write(String content, boolean isAppend) throws IORuntimeException {
		BufferedWriter writer = null;
		try {
			writer = getWriter(isAppend);
			writer.write(content);
			writer.flush();
		}catch(IOException e){
			throw new IORuntimeException(e);
		}finally {
			IoUtil.close(writer);
		}
		return file;
	}
305279
function writeFile(filename, content) {
  fs.writeFileSync(filename, JSON.stringify(content, null, 2));
}
1277665
public static void writeOutContent(final byte[] data, final String filename, final String mime) {
        writeOutContent(data, filename, mime, true);
    }
619758
public void writeContent(final OutputStream result) throws IOException
    {
        if(this.content.size() == 0) {
            result.write(RtfParagraph.PARAGRAPH_DEFAULTS);
            if(this.parentRow.getParentTable().getTableFitToPage()) {
                result.write(RtfParagraphStyle.KEEP_TOGETHER_WITH_NEXT);
            }
            result.write(RtfParagraph.IN_TABLE);
        } else {
            for(int i = 0; i < this.content.size(); i++) {
                RtfBasicElement rtfElement = (RtfBasicElement) this.content.get(i);
                if(rtfElement instanceof RtfParagraph) {
                    ((RtfParagraph) rtfElement).setKeepTogetherWithNext(this.parentRow.getParentTable().getTableFitToPage());
                }
                rtfElement.writeContent(result);
                if(rtfElement instanceof RtfParagraph && i < (this.content.size() - 1)) {
                    result.write(RtfParagraph.PARAGRAPH);
                }
            }
        }
        result.write(DocWriter.getISOBytes("\\cell"));
    }
781148
public void writeContent(final OutputStream out) throws IOException
    {
    	final byte[] contentBytes = DocWriter.getISOBytes(this.directContent);
   		out.write(contentBytes);
    }
359935
public function writeContent()
    {
        $dirPath = dirname($this->getPath());

        if (!is_dir($dirPath)) {
            mkdir($dirPath, 0755, true);
        }

        file_put_contents(
            $this->getPath(),
            $this->getContent()
        );
    }