java.io.PrintWriter.checkError() 方法刷新该流,如果它不是关闭,并检查其错误状态。
声明
以下是java.io.PrintWriter.checkError()方法的声明
public boolean checkError()
参数
-
NA
返回值
如果打印流遇到了一个错误该方法返回true,无论是在基础输出流或在格式转换过程。
异常
-
NA
例子
下面的示例演示java.io.PrintWriter.checkError()方法的用法。
package com.yiibai; import java.io.*; public class PrintWriterDemo { public static void main(String[] args) { String s = "Hello World "; // create a new stream at system PrintWriter pw = new PrintWriter(System.out); // append the sequence pw.append(s); // check if there is an error and flush System.out.println("" + pw.checkError()); } }
Let us compile and run the above program, this will produce the following result
Hello Worldfalse