您的位置:首页 > 编程语言 > Java开发

Java Exception

2014-04-09 05:36 218 查看
0. 什么时候用catch,什么时候用throws
http://stackoverflow.com/questions/11853348/throwing-and-catching-exceptions

Throwing and Catching Exceptions

http://www.onjava.com/pub/a/onjava/2003/11/19/exceptions.html

Best Practices for Exception Handling

1. print exception

Printing Exception Message in java http://stackoverflow.com/questions/15722763/printing-exception-message-in-java
try {
// ----
} catch (javax.script.ScriptException ex) {
System.out.println(ex.getMessage());
}


2. print stack trace
http://stackoverflow.com/questions/2560368/what-is-the-use-of-printstacktrace-method-in-java
catch(IOException ioe)
{
ioe.printStackTrace();
}


no error trace

for (StackTraceElement ste : Thread.currentThread().getStackTrace()) {
System.out.println(ste);
}

http://stackoverflow.com/questions/1069066/get-current-stack-trace-in-java Get current stack trace in Java
http://stackoverflow.com/questions/1149703/stacktrace-to-string-in-java Stacktrace to string in Java
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: