How to check whether an OutputStream is closed
Is there anyway to check whether an OutputStream is closed without attempting to write to it and catching the IOException ? For example, consider the following contrived method: public boolean isStreamClosed(OutputStream out){ if( /* stream isn't closed */){ return true; }else{ return false; } } What could you replace /* stream isn't closed */ with? The underlying stream may not know it its closed until you attempt to write to it (e.g. if the other end of a socket closes it) The simplest approach is to use it and handle what happens if it closed then, rather than testing it first as well. No