按javadoc:
Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
此外,如果查看代码,则刷新和关闭都是ByteArrayOutputStream类中的无操作(尽管flush是从OutputStream继承的,但它在OutputStream中是无操作,除非在特定实现中被覆盖).