Java.io.PrintStream.format() 方法


Java.io.PrintStream.format() 方法

package com.codingdict;



import java.io.*;

import java.util.Locale;



public class PrintStreamDemo {



   public static void main(String[] args) {

      String s = "Hello World";



      // create printstream object

      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();

   }

}