在 finally 子句中编写 try 和 catch 是否被认为是糟糕的编程?
我在我的主要方法中有一个我想关闭的 fileInputStream。我想将 .close() 放在最后,所以无论如何它都会关闭。我不想在 main 方法中添加 throws 声明,因为它是 main 方法:P
}finally{
try {
commandFile.close();
} catch (IOException e) {
throwException(e);
}
}
可以吗?谢谢