Good afternoon all. I am aware that if we close() an java.io.OutputStream, it may throw an IOException when there are hard disk errors.
As for java.io.InputStream, Javamex states that:
A normal closure of a network socket actually involves a closure request (TCP/IP FIN packet) being sent over the connection and waiting for the other end to acknowledge this closure request. (In fact, the other end of the connection then in turn sends a closure request, which the closing end acknowledges.) So in the case of a socket input stream, a closure operation actually involves sending traffic over the connection and the closure can thus fail with an error.
Now I was wondering exactly under what circumstances will a java.io.InputStream (or sub class) for a local file (network access not needed) ever throw an exception when we call close() ?
Here’s one situation:
close()function, it may get anEBADFerror indicating that the file handle is invalid.The above situation probably indicates a serious bug somewhere else in the application.