Java: Why doesn't the PrintWriter or PrintStream class throw an exception?

Possible duplicate:
PrintWriter and PrintStream never throw IOExceptions

Maybe the question is a bit "weird." But I'm curious to know why both PrintWriter and PrintStream do not automatically check for runtime exceptions, and they provide a checkError () method.

Thanks to everyone in advance.

+5
source share
2 answers

For a PrintStream, which is often written to std out or err, this stream may be closed or dropped, but you do not want the program to unexpectedly fail as a result.

PrintWriter PrintStream Writer, , PrintStream.;)

, PrintWriter , IOException Socket, , .

+5

, , System.err - PrintStream.

catch, e.printStackTrace() System.err. , PrintStream. try/catch catch, , .

, JDK 1.7 catch .

+1

All Articles