a question about closing a stream/socket in java

benjamin :

when does the methods socket.close() and someStream.close() throws IOException? and how can I solve the problem?

thanks benny.

Sjoerd :

Not checking the return value of close() is a common but nevertheless serious programming error. It is quite possible that errors on a previous write(2) operation are first reported at the final close(). Not checking the return value when closing the file may lead to silent loss of data. This can especially be observed with NFS and with disk quota.

While closing a readonly stream can't throw, java's IO framework can't check for that as it doesn't have statically checked read vs. write streams

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related