Java tutorial
import java.io.BufferedWriter; import java.io.FileWriter; public class Main { public static void main(String[] args) throws Exception { String multilineString = "This is line 1\nthis is line 2\nthis is last line"; FileWriter fileWriter = new FileWriter("multiline.txt", true); BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); bufferedWriter.write(multilineString + "\n"); bufferedWriter.flush(); bufferedWriter.close(); fileWriter.close(); } }