Create PrintWriter from BufferedWriter : PrintWriter « File Input Output « Java






Create PrintWriter from BufferedWriter

   


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

class MainClass {

  public static void main(String args[]) throws Exception {

    FileWriter fw = new FileWriter(args[0]);
    BufferedWriter bw = new BufferedWriter(fw);
    PrintWriter pw = new PrintWriter(bw, false);


    pw.println(true);
    pw.println('A');
    pw.println(500);
    pw.println(40000L);
    pw.println(45.67f);
    pw.println(45.67);
    pw.println("Hello");
    pw.println(new Integer("99"));


    pw.close();
  }
}

   
    
    
  








Related examples in the same category

1.Create PrintWriter from System.out
2.Create PrintWriter out of FileWriter
3.Write lines of text to file using a PrintWriter
4.A PrintWriter that ends lines with a carriage return-line feed (CRLF).
5.A PrintWriter that also sends its output to a log stream
6.A helper class for printing indented text