Java PrintWriter write String to a file

Description

Java PrintWriter write String to a file

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.PrintWriter;

public class Main {
  public static void main(String[] args) throws Exception {
    PrintWriter out1 = new PrintWriter(new BufferedWriter(new FileWriter("Main.out")));
    out1.println("demo from demo2s.com");
    out1.close();//from  w w  w .  ja va 2  s  .c  o  m
    System.out.println("done");
  }
}



PreviousNext

Related