Java tutorial
//package com.java2s; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class Main { /** * Write data to file. * * @param fileName * @param message */ public static void write2File(String fileName, String message, boolean append) { try { FileOutputStream outStream = new FileOutputStream(fileName, append); byte[] bytes = message.getBytes(); outStream.write(bytes); outStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }