StreamUtils comes with nonClosing decoration methods already, based on an internal NonClosingOutputStream class which suppresses close() calls. We can easily add support for a nonFlushing method, applying an internal subclass of NonClosingOutputStream that also suppresses flush() calls. Also, we can detect whether a given OutputStream is non-closing/flushing already and avoid unnecessary decoration in that case.
StreamUtilscomes withnonClosingdecoration methods already, based on an internalNonClosingOutputStreamclass which suppressesclose()calls. We can easily add support for anonFlushingmethod, applying an internal subclass ofNonClosingOutputStreamthat also suppressesflush()calls. Also, we can detect whether a givenOutputStreamis non-closing/flushing already and avoid unnecessary decoration in that case.