Here you can find the source of writeFileByChar(String content, String filename, String encoding)
public static void writeFileByChar(String content, String filename, String encoding)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.io.Writer; public class Main { public static void writeFileByChar(String content, String filename, String encoding) { File file = new File(filename); Writer writer = null;// w w w . ja va2 s. c om try { if (null == encoding || "".equals(encoding)) { writer = new OutputStreamWriter(new FileOutputStream(file)); } else { writer = new OutputStreamWriter(new FileOutputStream(file), encoding); } writer.write(content); } catch (Exception e) { e.printStackTrace(); } finally { if (writer != null) { try { writer.close(); } catch (Exception e1) { e1.printStackTrace(); } } } } }