Is there anyway to check whether an OutputStream is closed without attempting to write to it and catching the IOException?
For example, consider the fol
No. If you implement your own, you could write an isClosed method, but if you don't know the concrete class, then no. OutputStream is just an abstract class. Here's it's implementation:
/**
* Closes this output stream and releases any system resources
* associated with this stream. The general contract of close
* is that it closes the output stream. A closed stream cannot perform
* output operations and cannot be reopened.
*
* The close method of OutputStream does nothing.
*
* @exception IOException if an I/O error occurs.
*/
public void close() throws IOException {
}