有名大站 » Blog Archive » JAVA-Exception

JAVA-Exception

package exception; import java.util.Scanner ; import java.io.*; class ExceptionFather{ public String readString() throws FileNotFoundException{ Scanner s = new Scanner (new File("input.txt")); return "ExceptionFather -"+ s.next() ; } } class ExceptionSon extends ExceptionFather{ @Override public String readString() { Scanner s=null; String temp=null; try{ s=new Scanner(new File ("input.txt")); temp="ExceptionSon-"+s.next(); }catch (FileNotFoundException fnfe ){ System.out.println("例外="+fnfe.toString()); }finally { System.out.println("Finally"); } return temp; } } public class TestException{ public static void main(String [] args){ ExceptionSon s=new ExceptionSon(); System.out.println(s.readString()); try{ ExceptionFather f=new ExceptionFather(); System.out.println(f.readString()); }catch(FileNotFoundException fnfe){ fnfe.printStackTrace(); } } }

1則回覆

  1. 2009/10/11 at 09:57
    Crazy61 說 :

    Family meetings begin with the family team members being introduced to each other. ,

給個回覆

使用Facebook帳號留言

支持FaceBook帳戶留言,歡迎多加利用

E-Mail (不會被公開) (支援Gravatar大頭貼)

:az: :ay: :ax: :aw: :av: :au: :at: :as: :ar: :aq: :ap: :ao: :an: :am: :al: :ak: :aj: :ai: :ah: :ag: :af: :ae: :ad: :ac: :ab: :aa:

« 上一篇文章
»下一篇文章