ExceptionHandling蔡文能交通大学资讯工程学系tsaiwn@csie.nctu.ppt

ExceptionHandling蔡文能交通大学资讯工程学系tsaiwn@csie.nctu.ppt

ExceptionHandling蔡文能交通大学资讯工程学系tsaiwn@csie.nctu.ppt

Programming in Java Exception Handling 蔡文能 交通大學資訊工程學系 tsaiwn@.tw Exception example try { readFromFile(datafile); } catch (FileNotFoundException e) { System.err.println(Error: File not found); } Exception Handling: Some Options Print something Throw a new exception Re-Throw the exception Fix the problem Exit Exception Handling: Printing You can print a stack trace by calling the exception method printStackTrace() Sometimes its better to send error messages to stderr: System.err.println(Error: invalid thingy); Some applications log error messages file logging service (syslog). Excepti

文档评论(0)

1亿VIP精品文档

相关文档