Here you can find the source of writeFile(String content, File file, Charset encoding)
public static void writeFile(String content, File file, Charset encoding) throws IOException
//package com.java2s; /*/* w w w . ja va 2 s . c o m*/ * This software is Copyright by the Board of Trustees of Michigan * State University (c) Copyright 2013, 2014. * * You may use this software under the terms of the GNU public license * (GPL). The terms of this license are described at: * http://www.gnu.org/licenses/gpl.txt * * Contact Information: * Facility for Rare Isotope Beam * Michigan State University * East Lansing, MI 48824-1321 * http://frib.msu.edu */ import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.Charset; public class Main { public static void writeFile(String content, File file, Charset encoding) throws IOException { try (Writer out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file), encoding))) { out.write(content); } } }