Java.io.PrintWriter.clearError() 方法 Java.io.PrintWriter.checkError() 方法 Java.io.PrintWriter.close() 方法 Java.io.PrintWriter.clearError() 方法 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(); // clear the errors, if there are any pw.clearError(); } } Java.io.PrintWriter.checkError() 方法 Java.io.PrintWriter.close() 方法