Java.io.PrintWriter.setError() 方法 Java.io.PrintWriter.println String() 方法 Java.io.PrintWriter.write Char() 方法 Java.io.PrintWriter.setError() 方法 package com.codingdict; import java.io.*; public class PrintWriterDemo extends PrintWriter { public PrintWriterDemo(OutputStream out) { super(System.out); } public static void main(String[] args) { String s = "Hello World"; // create a new writer PrintWriterDemo pw = new PrintWriterDemo(System.out); // write substrings pw.write(s, 0, 5); pw.write(s, 6, 5); // flush the writer pw.flush(); // set the error state pw.setError(); } } Java.io.PrintWriter.println String() 方法 Java.io.PrintWriter.write Char() 方法