Exception的说明
    参考:https://docs.oracle.com/javase/8/docs/api/

    检查异常的定义 The class Exception and any subclasses that are not also subclasses of RuntimeException are checked exceptions

    1. //继承Exception的检查异常
    2. class SimpleException extends Exception{}
    3. public class InheritingException {
    4. /*
    5. throw 抛出异常 可以进行try catch来自己处理或者使用关键字throws让调用者处理
    6. throws 如果本方法无法处理得话 在方法签名上进行throws 让调用者处理
    7. */
    8. public void f() throws SimpleException{
    9. System.out.println("Throwing SimpleException from f()");
    10. //检查异常在编译阶段都会提示用户进行处理
    11. //如果抛出检查异常的话,1,要么自己显示的处理;2,要么在方法签名处抛出,交给调用者处理
    12. throw new SimpleException();
    13. }
    14. public static void main(String[] args) {
    15. InheritingException inheritingException = new InheritingException();
    16. try {
    17. //调用者进行显示处理
    18. inheritingException.f();
    19. }catch (SimpleException e){
    20. System.err.println("Cautht f()");
    21. }
    22. }
    23. }
                   检查异常                                                                                             运行异常<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/96947/1617691249673-ae77f09b-fd07-43a9-b57d-8cae769cbd37.png#align=left&display=inline&height=258&margin=%5Bobject%20Object%5D&name=image.png&originHeight=516&originWidth=491&size=18659&status=done&style=none&width=245.5)                                                      ![image.png](https://cdn.nlark.com/yuque/0/2021/png/96947/1617691338491-42bc58b9-441f-4f04-a827-0d4c6cee9bd2.png#align=left&display=inline&height=259&margin=%5Bobject%20Object%5D&name=image.png&originHeight=517&originWidth=393&size=16625&status=done&style=none&width=196.5)<br />                                       综合对比<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/96947/1617691857672-1e17dfd9-49f5-47e3-92c3-6e4c09960031.png#align=left&display=inline&height=259&margin=%5Bobject%20Object%5D&name=image.png&originHeight=518&originWidth=869&size=28589&status=done&style=none&width=434.5)
    
    // FileOutputStream 部分源码如下
    public FileOutputStream(File file, boolean append)
            throws FileNotFoundException //此处为检查异常的抛出
        {
            String name = (file != null ? file.getPath() : null);
            SecurityManager security = System.getSecurityManager();
            if (security != null) {
                security.checkWrite(name);
            }
            if (name == null) {
                throw new NullPointerException();//运行时运行,从Diagrams图可以看出与FileNotFoundException并无继承体系关系
            }
            if (file.isInvalid()) {
                throw new FileNotFoundException("Invalid file path");//抛出检查异常
            }
            this.fd = new FileDescriptor();
            fd.attach(this);
            this.append = append;
            this.path = name;
    
            open(name, append);
        }