Creates a file using the supplied content.
@param dir directory to create file in.
@param fileName name for file.
@param content content to save.
@return link to created file.
776892
protected String createFile(String dir, String fileName, byte[] content) {
        String baseName = FilenameUtils.getBaseName(fileName);
        String ext = FilenameUtils.getExtension(fileName);
        String downloadedFile = FileUtil.saveToFile(dir + baseName, ext, content);
        return linkToFile(downloadedFile);
    }
273442
function contentScope(content, file) {
    if (file) { // 已指定
      file = path.resolve(getDirname(), file);
    } else { // 未指定
      file = filename;
    }
    return create({
      fromString: true,
      content: content,
      clean: clean,
      removeList: removeList,
      excludeList: excludeList,
      rootScope: rootScope,
      filename: file,
      argv: argv,
      scopes: scopes,
      processors: processors,
      variants: variants,
      cacheKeys: cacheKeys,
      tags: tags
    });
  }
1203162
function saveContentToFile(filePrefix, content) {
  var dirPath = getWebHookDirectory();
  var filePath = path.join(dirPath, filePrefix + '#' + ASSOCIATION_FILE_NAME);

  // create all directories from file path
  createDirectoriesIfNeeded(dirPath);

  // write content to the file
  try {
    fs.writeFileSync(filePath, JSON.stringify(content, null, 2), 'utf8');
  } catch (err) {
    console.log(err);
  }
}
1251770
public function createFile($filename, $content)
    {
        if (false === $this->createDirectory(dirname($filename))) {
            return false;
        }

        Silencer::call('file_put_contents', $filename, $content);
        Silencer::call('chmod', $filename, 0755);

        return true;
    }
144815
public static File appendString(String content, File file, String charset) throws IORuntimeException {
		return FileWriter.create(file, CharsetUtil.charset(charset)).append(content);
	}
1235226
public static JsonArrayDocument create(String id, JsonArray content) {
        return new JsonArrayDocument(id, 0, content, 0, null);
    }
873191
function(fileName, content) {
                return Promise()
                .then(function() {
                    var filePath = PathUtils.resolveInRoot(outputFolder, fileName);

                    return fs.ensureFile(filePath)
                    .then(function() {
                        return fs.writeFile(filePath, content);
                    });
                });
            }
1010816
private void createReportFile(String reportFileName, String content) {
        File targetDirectory = new File(getReportDirectory());
        if (!targetDirectory.exists()) {
            if (!targetDirectory.mkdirs()) {
                throw new CitrusRuntimeException("Unable to create report output directory: " + getReportDirectory());
            }
        }

        try (Writer fileWriter = new FileWriter(new File(targetDirectory, reportFileName))) {
            fileWriter.append(content);
            fileWriter.flush();
            log.info("Generated test report: " + targetDirectory + File.separator + reportFileName);
        } catch (IOException e) {
            log.error("Failed to create test report", e);
        }
    }
961633
public void stringToFile(String content, File file) throws IOException {
        stringToOutputStream(content, new FileOutputStream(file));
    }
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;
	}
1357689
public static void createFile(String output, String content) throws Exception {
		OutputStreamWriter fw = null;
		PrintWriter out = null;
		try {
			if (ENCODING == null)
				ENCODING = PropsUtil.ENCODING;

			fw = new OutputStreamWriter(new FileOutputStream(output), ENCODING);
			out = new PrintWriter(fw);
			out.print(content);
		} catch (Exception ex) {
			throw new Exception(ex);
		} finally {
			if (out != null)
				out.close();
			if (fw != null)
				fw.close();
		}

	}
620477
public static File createTmpDir(String directoryName) {
        File tmpDir = new File(System.getProperty("java.io.tmpdir"));
        File testDir = new File(tmpDir, directoryName);
        if(!testDir.mkdir()) {
            throw new ResourceUtilException("Can't create directory: " + testDir.getAbsolutePath());
        }
        testDir.deleteOnExit();
        return testDir;
    }
244437
function(/**string*/ outDir, /**string*/ fileName, /**string*/ content) {
		fs.writeFileSync(outDir + "/" + fileName, content, IO.encoding);
	}
186918
public MultipartBuilder attachment(String content, String filename) {
        ByteArrayInputStream is = new ByteArrayInputStream(content.getBytes());
        return bodyPart(new StreamDataBodyPart(ATTACHMENT_NAME, is, filename));
    }
1084537
public HttpPut createContentPutMethod(final String path, final Map<String, List<String>> params,
                                          final FedoraContent content ) {
        String contentPath = path;
        if ( content != null && content.getChecksum() != null ) {
            contentPath += "?checksum=" + content.getChecksum();
        }

        final HttpPut put = createPutMethod( contentPath, params );

        // content stream
        if ( content != null ) {
            put.setEntity( new InputStreamEntity(content.getContent()) );
        }

        // filename
        if ( content != null && content.getFilename() != null ) {
            put.setHeader("Content-Disposition", "attachment; filename=\"" + content.getFilename() + "\"" );
        }

        // content type
        if ( content != null && content.getContentType() != null ) {
            put.setHeader("Content-Type", content.getContentType() );
        }

        return put;
    }
414933
public static File createPictureFile(String dirName) {
        String timeStamp = IMG_FILE_NAME_FORMAT.format(new Date());
        String imageFileName = PREFIX_IMAGE + timeStamp + EXTENSION_JPEG;
        return new File(getPicturesDir(dirName), imageFileName);
    }
1355589
function (content) {
      var innerSelf = this;

      return self._readFile()
        .then(function (fileContent) {
          fileContent.instances = fileContent.instances || {};
          fileContent.instances[innerSelf._id] = _.assign(fileContent.instances[innerSelf._id] || {}, content);

          return self._writeFile(fileContent);
        });
    }