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
Unfortunately OutputStream API does not have method like isClosed().
So, I know only one clear way: create your class StatusKnowingOutputStream that wraps any other output stream and implements its close() method as following:
public void close() {
out.close();
closed = true;
}
Now add method isClosed()
public boolean isClosed() {
return closed;
}