Is java – bytearrayoutputstream secure without flush() and close()?

So, will bytearrayoutputstream cause memory overflow if it is not refreshed and closed correctly? I mean, is it necessary for them to put code into Java or garbage collect it?

Solution

No, it collects garbage after the last reference is lost

Press Javadoc:

In addition, if you look at the code, both refresh and close are no operations in the bytearrayoutputstream class (although flush inherits from OutputStream, it is no operation in OutputStream unless overridden in a specific implementation)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>