Android examples for java.io:OutputStreamWriter
write To Txt file using OutputStreamWriter
import java.io.BufferedWriter; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.nio.charset.Charset; public class Main { public static void writeToTxt(String fileName, String content) { try {//from ww w .j a va 2 s. c o m OutputStreamWriter write = null; BufferedWriter out = null; if (fileName != null) { try { write = new OutputStreamWriter(new FileOutputStream(fileName, true), Charset.forName("UTF-16")); out = new BufferedWriter(write); } catch (Exception e) { } } out.write(content + "\r\n"); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } } }