Here you can find the source of appendToLog(String content, Path newFile)
public static void appendToLog(String content, Path newFile)
//package com.java2s; //License from project: LGPL import java.io.BufferedWriter; import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.OpenOption; import java.nio.file.Path; import java.nio.file.StandardOpenOption; public class Main { public static void appendToLog(String content, Path newFile) { //Writing to file try (BufferedWriter writer = Files.newBufferedWriter(newFile, Charset.defaultCharset(), new OpenOption[] { StandardOpenOption.APPEND })) { writer.append(content);//w w w . j a v a2 s .c om writer.append("\n"); writer.flush(); } catch (IOException exception) { System.out.println("Error writing to file"); } } }