method(); has declare throws Exception, not other Exception
Then the method may throws other type exception

解决方案 »

  1.   

    the Exception catch including a class match process , you can write code catch father class and catch sub class on runtime , when throw exceptions , the subclass will cast to declared throws class type, that meas throws class Exception based on the declaration of method(), and because Exception class is the root class of Exception class tree , so you have to declare catch Exception class .
      

  2.   

    你所 catch的exception必须是函数 method()声明抛出的 exception 或者其父类。
      

  3.   

    原因很简单
    static void method() throws Exception{}
    看这句,你声明的异常为Exception,虽然实际抛出的为EOFException。
    catch应该捕捉你声明的异常而不是实际的。