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

		File targetFile = new File( this.outputDirectory, "index.md" );
		Utils.createDirectory( targetFile.getParentFile());
		Utils.writeStringInto( fileContent.replaceAll( "\n{3,}", "\n\n" ), targetFile );

		return targetFile;
	}
317861
private void writeFileByte(byte[] content, File file) throws IOException {

        FileOutputStream fOut = null;
        DataOutputStream dOut = null;
        try {
            // write the content to the file in server filesystem
            fOut = new FileOutputStream(file);
            dOut = new DataOutputStream(fOut);
            dOut.write(content);
            dOut.flush();
        } catch (IOException e) {
            throw e;
        } finally {
            try {
                if (fOut != null) {
                    fOut.close();
                }
            } catch (IOException e) {
                // ignore
            }
            try {
                if (dOut != null) {
                    dOut.close();
                }
            } catch (IOException e) {
                // ignore
            }
        }
    }
781148
public void writeContent(final OutputStream out) throws IOException
    {
    	final byte[] contentBytes = DocWriter.getISOBytes(this.directContent);
   		out.write(contentBytes);
    }
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);
	}
915968
@SuppressWarnings("UnusedDeclaration")
  public static void printContent( String strContent , boolean escape )
  {
    try
    {
      RuntimeData pair = getRuntimeData();
      Writer writer = pair._writer;

      if (escape && pair._esc != null) {
        strContent = pair._esc.escape(strContent);
      } else if (pair._esc instanceof IEscapesAllContent) {
        strContent = ((IEscapesAllContent)pair._esc).escapeBody(strContent);
      }

      writer.write( strContent == null ? "null" : strContent );
    }
    catch( IOException e )
    {
      throw new RuntimeException( e );
    }
  }
485303
public void writeContent(final OutputStream result) throws IOException
    {
        try {
            // This is so that all color, font and similar information is processed once, before
            // the header section is written.
            writeSectionDefinition(new RtfNilOutputStream());
            
            this.codePage.writeDefinition(result);
            this.fontList.writeDefinition(result);
            this.colorList.writeDefinition(result);
            this.stylesheetList.writeDefinition(result);
            this.listTable.writeDefinition(result);
            this.generator.writeContent(result);
            this.infoGroup.writeContent(result);
            this.protectionSetting.writeDefinition(result);
            this.pageSetting.writeDefinition(result);
            
            writeSectionDefinition(result);
        } catch(IOException ioe) {
            ioe.printStackTrace();
        }
    }
82436
public void writeContent(final OutputStream result) throws IOException
    {
        result.write(PARAGRAPH_DEFAULTS);
        result.write(PLAIN);
        if(inTable) {
            result.write(IN_TABLE);
        }
        if(this.lineLeading > 0) {
            result.write(LINE_SPACING);
            result.write(intToByteArray(this.lineLeading));
        }
        for(int i = 0; i < chunks.size(); i++) {
        	RtfBasicElement rbe = (RtfBasicElement) chunks.get(i);
        	rbe.writeContent(result);
        }
    }
636665
public static void writeContent(CharSequence content, File file, String encoding) {
        OutputStream os = null;
        try {
            os = new FileOutputStream(file);
            PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(os, encoding));
            printWriter.println(content);
            printWriter.flush();
            os.flush();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                if (os != null) os.close();
            } catch (Exception e) {
                //
            }
        }
    }
115700
public void writeContent(final OutputStream result) throws IOException
    {
        Iterator it = this.borders.values().iterator();
        while(it.hasNext()) {
            ((RtfBorder) it.next()).writeContent(result);
        }
    }
222346
private void writeContent() throws CmsException {

        String decodedContent = m_content.toString();
        try {
            m_file.setContents(decodedContent.getBytes(getFileEncoding()));
        } catch (UnsupportedEncodingException e) {
            throw new CmsException(Messages.get().container(Messages.ERR_INVALID_CONTENT_ENC_1, getParamResource()), e);
        }
        // the file content might have been modified during the write operation
        CmsObject cloneCms = getCloneCms();
        CmsUUID tempProjectId = OpenCms.getWorkplaceManager().getTempFileProjectId();
        cloneCms.getRequestContext().setCurrentProject(getCms().readProject(tempProjectId));
        m_file = cloneCms.writeFile(m_file);
        m_content = CmsXmlContentFactory.unmarshal(cloneCms, m_file);

    }
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);
        }
    }
499672
public void writeContent(final OutputStream result) throws IOException
    {
		this.shapeNr = this.doc.getRandomInt();
		
		this.properties.put("ShapeType", new RtfShapeProperty("ShapeType", this.type));
		if(this.position.isShapeBelowText()) {
			this.properties.put("fBehindDocument", new RtfShapeProperty("fBehindDocument", true));
		}
		if(this.inTable) {
			this.properties.put("fLayoutInCell", new RtfShapeProperty("fLayoutInCell", true));
		}
		if(this.properties.containsKey("posh")) {
			this.position.setIgnoreXRelative(true);
		}
		if(this.properties.containsKey("posv")) {
			this.position.setIgnoreYRelative(true);
		}
    	
    	result.write(OPEN_GROUP);
    	result.write(DocWriter.getISOBytes("\\shp"));
    	result.write(DocWriter.getISOBytes("\\shplid"));
    	result.write(intToByteArray(this.shapeNr));
    	this.position.writeContent(result);
    	switch(this.wrapping) {
    	case SHAPE_WRAP_NONE:
    		result.write(DocWriter.getISOBytes("\\shpwr3"));
    		break;
    	case SHAPE_WRAP_TOP_BOTTOM:
    		result.write(DocWriter.getISOBytes("\\shpwr1"));
    		break;
    	case SHAPE_WRAP_BOTH:
    		result.write(DocWriter.getISOBytes("\\shpwr2"));
    		result.write(DocWriter.getISOBytes("\\shpwrk0"));
    		break;
    	case SHAPE_WRAP_LEFT:
    		result.write(DocWriter.getISOBytes("\\shpwr2"));
    		result.write(DocWriter.getISOBytes("\\shpwrk1"));
    		break;
    	case SHAPE_WRAP_RIGHT:
    		result.write(DocWriter.getISOBytes("\\shpwr2"));
    		result.write(DocWriter.getISOBytes("\\shpwrk2"));
    		break;
    	case SHAPE_WRAP_LARGEST:
    		result.write(DocWriter.getISOBytes("\\shpwr2"));
    		result.write(DocWriter.getISOBytes("\\shpwrk3"));
    		break;
    	case SHAPE_WRAP_TIGHT_BOTH:
    		result.write(DocWriter.getISOBytes("\\shpwr4"));
    		result.write(DocWriter.getISOBytes("\\shpwrk0"));
    		break;
    	case SHAPE_WRAP_TIGHT_LEFT:
    		result.write(DocWriter.getISOBytes("\\shpwr4"));
    		result.write(DocWriter.getISOBytes("\\shpwrk1"));
    		break;
    	case SHAPE_WRAP_TIGHT_RIGHT:
    		result.write(DocWriter.getISOBytes("\\shpwr4"));
    		result.write(DocWriter.getISOBytes("\\shpwrk2"));
    		break;
    	case SHAPE_WRAP_TIGHT_LARGEST:
    		result.write(DocWriter.getISOBytes("\\shpwr4"));
    		result.write(DocWriter.getISOBytes("\\shpwrk3"));
    		break;
    	case SHAPE_WRAP_THROUGH:
    		result.write(DocWriter.getISOBytes("\\shpwr5"));
    		break;
    	default:
    		result.write(DocWriter.getISOBytes("\\shpwr3"));
    	}
    	if(this.inHeader) {
    		result.write(DocWriter.getISOBytes("\\shpfhdr1"));
    	} 
    	this.doc.outputDebugLinebreak(result);
    	result.write(OPEN_GROUP);
    	result.write(DocWriter.getISOBytes("\\*\\shpinst"));
    	Iterator it = this.properties.values().iterator();
    	while(it.hasNext()) {
    		RtfShapeProperty rsp = (RtfShapeProperty) it.next();
    		rsp.setRtfDocument(this.doc);
    		rsp.writeContent(result);
    	}
    	if(!this.shapeText.equals("")) {
    		result.write(OPEN_GROUP);
    		result.write(DocWriter.getISOBytes("\\shptxt"));
    		result.write(DELIMITER);
    		result.write(DocWriter.getISOBytes(this.shapeText));
    		result.write(CLOSE_GROUP);
    	}
    	result.write(CLOSE_GROUP);
    	this.doc.outputDebugLinebreak(result);
    	result.write(CLOSE_GROUP);
		
    }
1227384
@Override
    public void writeContent(XMLExtendedStreamWriter writer, Resource value) throws XMLStreamException {

        if(value != null && this != value) {
            throw new IllegalStateException("Wrong target resource.");
        }

        writer.writeStartElement(ModuleConfigImpl.RESOURCE_ROOT);
        writer.writeAttribute(ModuleConfigImpl.PATH, path);
        writer.writeEndElement();
    }
726131
public void writeContent(final OutputStream result) throws IOException
    {    	
    	result.write(DocWriter.getISOBytes("\\shpleft"));
    	result.write(intToByteArray(this.left));
    	result.write(DocWriter.getISOBytes("\\shptop"));
    	result.write(intToByteArray(this.top));
    	result.write(DocWriter.getISOBytes("\\shpright"));
    	result.write(intToByteArray(this.right));
    	result.write(DocWriter.getISOBytes("\\shpbottom"));
    	result.write(intToByteArray(this.bottom));
    	result.write(DocWriter.getISOBytes("\\shpz"));
    	result.write(intToByteArray(this.zOrder));
    	switch(this.xRelativePos) {
    	case POSITION_X_RELATIVE_PAGE: result.write(DocWriter.getISOBytes("\\shpbxpage")); break;
    	case POSITION_X_RELATIVE_MARGIN: result.write(DocWriter.getISOBytes("\\shpbxmargin")); break;
    	case POSITION_X_RELATIVE_COLUMN: result.write(DocWriter.getISOBytes("\\shpbxcolumn")); break;
    	}
    	if(this.ignoreXRelative) {
    		result.write(DocWriter.getISOBytes("\\shpbxignore"));
    	}
    	switch(this.yRelativePos) {
    	case POSITION_Y_RELATIVE_PAGE: result.write(DocWriter.getISOBytes("\\shpbypage")); break;
    	case POSITION_Y_RELATIVE_MARGIN: result.write(DocWriter.getISOBytes("\\shpbymargin")); break;
    	case POSITION_Y_RELATIVE_PARAGRAPH: result.write(DocWriter.getISOBytes("\\shpbypara")); break;
    	}
    	if(this.ignoreYRelative) {
    		result.write(DocWriter.getISOBytes("\\shpbyignore"));
    	}
    	if(this.shapeBelowText) {
    		result.write(DocWriter.getISOBytes("\\shpfblwtxt1"));
    	} else {
    		result.write(DocWriter.getISOBytes("\\shpfblwtxt0"));
    	}
    }
400601
public static void writeStringToFile(String contents, String path, String encoding) throws IOException {
		OutputStream writer = null;
		if (path.endsWith(".gz")) {
      writer = new GZIPOutputStream(new FileOutputStream(path));
    } else {
      writer = new BufferedOutputStream(new FileOutputStream(path));
    }
		writer.write(contents.getBytes(encoding));
	}
1192047
public void writeContentBytes (@Nonnull @WillNotClose final OutputStream aOS) throws IOException
  {
    aOS.write (m_aContent, 0, m_aContent.length);
  }
176275
def writefile(filename, content):
    
    with open(path_expand(filename), 'w') as outfile:
        outfile.write(content)