Here you can find the source of writeString(File outputFile, String text)
public static void writeString(File outputFile, String text) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { private static String DEFAULT_ENCODING = "utf-8"; public static void writeString(File outputFile, String text, String encoding) throws IOException { writeBytes(outputFile, text.getBytes(encoding)); }/*from w w w. java2 s .co m*/ public static void writeString(File outputFile, String text) throws IOException { writeString(outputFile, text, DEFAULT_ENCODING); } public static void writeBytes(File outputFile, byte[] bytes) throws IOException { outputFile.getParentFile().mkdirs(); FileOutputStream outputStream = new FileOutputStream(outputFile); try { outputStream.write(bytes); } finally { outputStream.close(); } } }