public static void log(String text, String file) { System.out.println(text); boolean append = true; try { FileWriter fw = new FileWriter(file, append); fw.write(text + "\n"); fw.close(); } catch (IOException ex) { ex.printStackTrace(); } }