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