我这里有一个示例代码。当代码存在 parentFunction 的 try/catch 块时,函数创建的 FileInputStream 会自动关闭吗?
还是需要在 someOtherFunction() 本身中显式关闭它?
private void parentFunction() {
try {
someOtherFunction();
} catch (Exception ex) {
// do something here
}
}
private void someOtherFunction() {
FileInputStream stream = new FileInputStream(currentFile.toFile());
// do something with the stream.
// return, without closing the stream here
return ;
}