Here you can find the source of writeFile(File file, String content)
public static void writeFile(File file, String content) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.charset.StandardCharsets; public class Main { public static void writeFile(File file, String content) throws IOException { writeFile(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8), content); }//from w w w . j a v a2 s.co m private static void writeFile(Writer fw, String content) throws IOException { try { fw.write(content); fw.close(); } catch (IOException e) { closeSilently(fw); throw e; } } public static void closeSilently(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (IOException e) { // Do nothing } } } }