Java tutorial
//package com.java2s; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { /** * Write in a text file * * @param file * in which we write * * @param text * that we write * * @param append * indicates whether or not to append to an existing file * * @throws IOException * Input/Output exceptions */ public static void writeTextFile(File file, String text, boolean append) throws IOException { BufferedWriter writer = new BufferedWriter(new FileWriter(file, append)); writer.write(text); writer.close(); } }