Java tutorial
//package com.java2s; import java.io.*; public class Main { public static boolean writeTextContentToFile(String content, File dstFile) { return writeTextContentToFile(content, dstFile.getAbsolutePath()); } public static boolean writeTextContentToFile(String content, String dstPath) { BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(dstPath)); writer.write(content); return true; } catch (IOException e) { e.printStackTrace(); } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { e.printStackTrace(); } } } return false; } }