gpt4 book ai didi

java - 当我关闭 BufferedInputStream 时,底层的 InputStream 是否也关闭了?

转载 作者:太空狗 更新时间:2023-10-29 22:31:57 29 4
gpt4 key购买 nike

<分区>

InputStream in = SomeClass.getInputStream(...);
BufferedInputStream bis = new BufferedInputStream(in);

try {
// read data from bis
} finally {
bis.close();
in.close();
}

BufferedInputStream.close() 的 javadoc 没有提到底层流是否关闭:

Closes this input stream and releases any system resources associated with the stream. Once the stream has been closed, further read(), available(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

是否需要显式调用 in.close(),还是应该通过调用 bis.close() 来关闭?

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com