Java IO Tutorial - Java PrintStream.format(Locale l, String format, Object ... args)








Syntax

PrintStream.format(Locale l, String format, Object ... args) has the following syntax.

public PrintStream format(Locale l,   String format,   Object ... args)

Example

In the following code shows how to use PrintStream.format(Locale l, String format, Object ... args) method.

/*from ww  w  .j a va  2 s . c  om*/
import java.io.*;
import java.util.Locale;

public class Main {

   public static void main(String[] args) {
      String s = "from java2s.com";

      
      PrintStream ps = new PrintStream(System.out);

      // format a string
      ps.format(Locale.UK, "This is a %s program", s);

      // flush to see the string
      ps.flush();

   }
}

The code above generates the following result.