File Input Output Java

import java.io.BufferedWriter;
import java.io.FileWriter;
public class Main {
  public static void main(String[] args) throws Exception {
    BufferedWriter bufferedWriter = null;
    bufferedWriter = new BufferedWriter(new FileWriter("yourFile.txt"));
    bufferedWriter.write("string");
    bufferedWriter.newLine();
    bufferedWriter.write("string");
  }
}