Here you can find the source of writeFile(String fileName, String content, String encoding)
public static void writeFile(String fileName, String content, String encoding) throws IOException
//package com.java2s; /*/*from ww w.ja v a 2s .c o m*/ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved. * Use of this file is governed by the BSD 3-clause license that * can be found in the LICENSE.txt file in the project root. */ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { public static void writeFile(String fileName, String content) throws IOException { writeFile(fileName, content, null); } public static void writeFile(String fileName, String content, String encoding) throws IOException { File f = new File(fileName); FileOutputStream fos = new FileOutputStream(f); OutputStreamWriter osw; if (encoding != null) { osw = new OutputStreamWriter(fos, encoding); } else { osw = new OutputStreamWriter(fos); } try { osw.write(content); } finally { osw.close(); } } }