PrintWriter.println() has the following syntax.
public void println()
In the following code shows how to use PrintWriter.println() method.
import java.io.*; /*from w ww. ja va 2 s.c om*/ public class Main { public static void main(String[] args) { String s = "from java2s.com"; PrintWriter pw = new PrintWriter(System.out); // print string pw.print(s); // change the line twice pw.println(); pw.println(); // print another string pw.print("Two lines."); // flush the writer pw.flush(); } }
The code above generates the following result.