Java Streams   «Prev 

boolean checkError() method

public boolean checkError()

There are a number of IOException subclasses scattered around the other packages, particularly
I. java.util.zip
  1. DataFormatException and
  2. ZipException

and
II. java.net
  1. BindException,
  2. ConnectException,
  3. MalformedURLException,
  4. NoRouteToHostException,
  5. ProtocolException,
  6. SocketException,
  7. UnknownHostException, and
  8. UnknownServiceException

The java.io.IOException class declares no public methods or fields of significance, just the usual two constructors you find in most exception classes:
public IOException()
public IOException(String message)
The first constructor creates an IOException with an empty message. The second provides more details about what went wrong. Of course, IOException has the usual methods inherited by all exception classes such as toString() and printStackTrace().

The Universal IOException

Input and output are unreliable and are subject to problems completely outside the programmer's control.
  1. Disks can develop bad sectors while a file is being read;
  2. users unexpectedly cancel their input;
  3. telephone repair crews shut off your cable modem line while trying to repair someone else's.

Because of these potential problems, almost every method that performs input or output is declared to throw IOException. IOException is a checked exception, so you must either declare that your methods throw it or enclose the call that can throw it in a try/catch block. The only real exceptions to this rule are the PrintStream and PrintWriter classes. Because it would be inconvenient to wrap a try/catch block around each call to System.out.println(), Oracle decided to have PrintStream (and later PrintWriter) catch and eat any exceptions thrown inside a print() or println() method. If want to check for exceptions inside a print() or println() method, you can call checkError():
public boolean checkError()