Java IO Tutorial - 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.*;
//from w  ww .  j a va  2  s .  c  o  m
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.