Java append text to file

Java append text to file
/**
 * @author lautturi.com
 * Java example: how to append a string to the end of file in java
 */
import java.util.*;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;

public class Lautturi {

	public static void main(String[] args) {

		try {
			Path filePath = Paths.get("C:/", "temp", "test.txt");
			
			Files.write(filePath, "appended text".getBytes(), StandardOpenOption.APPEND);
			// or using writeString (jdk 11)
			//Files.writeString(filePath, "appended text", StandardOpenOption.APPEND);
        } 
        catch (IOException e) 
        {
        	//exception handling left as an exercise for the reader
            e.printStackTrace();
        }
	}
}
Source:ww‮al.w‬utturi.com
Created Time:2017-09-18 23:27:42  Author:lautturi