Here you can find the source of saveStats(String filename, String log)
public static void saveStats(String filename, String log)
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { public static void saveStats(String filename, String log) { BufferedWriter bw = null; FileWriter fw = null;//w w w . j a v a 2 s . com try { String data = log; File file = new File(filename); // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); } // true = append file fw = new FileWriter(file.getAbsoluteFile(), true); bw = new BufferedWriter(fw); bw.write(data); System.out.println("Log Written : " + filename); } catch (IOException e) { e.printStackTrace(); } finally { try { if (bw != null) bw.close(); if (fw != null) fw.close(); } catch (IOException ex) { ex.printStackTrace(); } } } }