io abnormal

For abnormal, JVM the default treatment options:

Once the program encounters a problem, it will put the issue of information like name, cause of the error, the error location printed on the console, so that we can observe.

And automatically stops away from the place of the current problem. Although this treatment program, but not good enough.

In fact, the program problems, should not be stopped directly, because our program may be a multi-part,
one part of the problem, and should not affect the execution of other parts.

Therefore, we should try to make the other parts can be implemented.

How we handle the exception, to ensure that it does not affect the various parts?
Two options:
A: the try ... the catch ... a finally
B: throws

the reason:读写数据的时候出现了错误,如 new一个文件流,路径有问题,会报异常

Guess you like

Origin www.cnblogs.com/wskb/p/10950846.html