PrintWriter.printf(String format, Object ... args) has the following syntax.
public PrintWriter printf(String format, Object ... args)
In the following code shows how to use PrintWriter.printf(String format, Object ... args) method.
//from w w w. ja v a 2s . c o m import java.io.*; import java.util.Locale; public class Main { public static void main(String[] args) { String s = "tutorial from java2s.com"; try { PrintWriter pw = new PrintWriter(System.out); // %s indicates a string will be placed there, which is s pw.printf("This is a %s program", s); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } } }
The code above generates the following result.