在我的finally子句中,我清理任何流,例如,
finally // Clean up
{
if (os != null) {
try {
os.close();
}
catch (IOException ioe) {
logger.warn("Failed to close outputStream", ioe);
}
}
if (is != null) {
try {
is.close();
}
catch (IOException ioe) {
logger.warn("Failed to close inputStream", ioe);
}
}
Run Code Online (Sandbox Code Playgroud)
但是我看到即使关闭后Streams仍然是非NULL.那么检查NULL是错误的吗?或者我没有看到结果close?
流"对象"是对流实例的引用.流是否开放是其州的一部分.close函数是一个在对象状态下运行的函数,因此不会影响对它的引用.
在将其设置为null之前,引用将保持非NULL,但是流的状态已关闭,这意味着您无法再使用它.
| 归档时间: |
|
| 查看次数: |
211 次 |
| 最近记录: |