Java PrintStream.checkError()
Syntax
PrintStream.checkError() has the following syntax.
public boolean checkError()
Example
In the following code shows how to use PrintStream.checkError() method.
import java.io.*;
/*w w w . j a v a2s.com*/
public class Main {
public static void main(String[] args) {
String s = "from java2s.com.";
// create a new PrintStream
PrintStream ps = new PrintStream(System.out);
// print a string
ps.println(s);
// check for errors and print
ps.print(ps.checkError());
ps.flush();
ps.close();
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »