Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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();
    }
}