illustrates using a PrintWriter to handle console output : Print To Files « File Input Output « Java






illustrates using a PrintWriter to handle console output

 

import java.io.PrintWriter;

public class PrintWriterDemo {
  public static void main(String args[]) {
    PrintWriter pw = new PrintWriter(System.out, true);
    pw.println("This is a string");
    int i = -7;
    pw.println(i);
    double d = 4.5e-7;
    pw.println(d);
  }
}

 








Related examples in the same category

1.Printing Numbers to a Text File
2.Printing an HTML Table