- Any OutputStream must be safe against double-close.
- Any buffering I/O layer must flush before close IF the close is not a no-op or double-close.
The options are:
- Double-close is invalid.
- The user is required to flush a buffer before close.
The interesting question is:
May flush() throw an IOException if the stream is closed, even if there is no buffered data to send?
The two axioms above make this question answerable either way. It doesn't matter. If you're closing, close all underlying streams you have access to, even if you then go on to close a network layer which has pointers to inner/filtered streams within them; it will be safe.