PrintWriter.printf(Locale l, String format, Object ... args) has the following syntax.
public PrintWriter printf(Locale l, String format, Object ... args)
In the following code shows how to use PrintWriter.printf(Locale l, String format, Object ... args) method.
/*from w w w . ja v a 2 s .com*/ 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); // printf text with specified locale. // %s indicates a string will be placed there, which is s pw.printf(Locale.UK, "This is a %s program", s); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } } }
The code above generates the following result.