Here you can find the source of saveStringToFile(String filename, String string)
public static boolean saveStringToFile(String filename, String string)
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { public static boolean saveStringToFile(String filename, String string) { boolean saved = false; BufferedWriter bw = null; if (string == null || filename == null) { throw new NullPointerException("Null String"); }// w ww . j a v a 2 s. c o m try { bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "UTF-8")); try { bw.write(string); saved = true; } finally { bw.close(); } } catch (IOException ex) { ex.printStackTrace(); } return saved; } }