Java tutorial
//package com.java2s; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; public class Main { public static boolean saveStringToFile(String fileName, String saveString) { boolean saved = false; BufferedWriter bw = null; try { bw = new BufferedWriter(new FileWriter(fileName)); try { bw.write(saveString); saved = true; } finally { bw.close(); } } catch (IOException ex) { ex.printStackTrace(); } return saved; } }