Java.io.PrintWriter.printf String() 方法 Java.io.PrintWriter.printf Locale() 方法 Java.io.PrintWriter.println() 方法 Java.io.PrintWriter.printf String() 方法 package com.codingdict; import java.io.*; import java.util.Locale; public class PrintWriterDemo { public static void main(String[] args) { String s = "Hello World"; try { // create a new writer PrintWriter pw = new PrintWriter(System.out); // printf text with default locale. // %s indicates a string will be placed there, which is s pw.printf("This is a %s program", s); // change line pw.println(); // printf text with default locale // %d indicates a integer will be placed there, which is 100 pw.printf("This is a %s program with %d", s, 100); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } } } Java.io.PrintWriter.printf Locale() 方法 Java.io.PrintWriter.println() 方法