【发布时间】:2012-01-30 22:22:13
【问题描述】:
是否可以在不使用 try catch 块的情况下将抛出的异常写入文件?
例如
public static void method() throws Exception, SQLException{
if(Exception is thrown){
write Exception to out.txt;
write SQLException to out.txt;
}
}
或者你必须这样做:
public static void method(){
try{
...
}catch(Exception ex){
write ex to file;
}catch(SQLException sqlex){
write sqlex to file;
}
}
【问题讨论】:
标签: java exception exception-handling throws