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