Here you can find the source of logLine(String filePath, String line)
public static void logLine(String filePath, String line)
//package com.java2s; //License from project: Apache License import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.util.Date; public class Main { public static void logLine(String filePath, String line) { if (filePath == null) { String log = (new Date()) + " : " + line + "\n"; System.out.print(log); } else {/*from www . j a v a 2 s.co m*/ try { BufferedWriter writer = new BufferedWriter(new FileWriter(filePath, true)); // writer.write((new Date())+" : "+line+"\n"); writer.write(line + "\n"); writer.flush(); writer.close(); } catch (IOException e) { e.printStackTrace(); } } } public static void logLine(String line) { logLine(null, line); } }