Name: jl125535 Date: 03/26/2004
A DESCRIPTION OF THE REQUEST :
Please provide an interface that will allow me to deal with closing io related objects uniformly.
e.g.
package java.io;
public interface IOClose {
public void close() throws IOException;
};
And make the following classes implement the interface.
java.io.Writer
java.io.Reader
java.io.InputStream
java.net.Socket
java.net.ServerSocket
java.net.DatagramSocket
java.nio.Channel
//---------------------------------------
And while you're at it, please do something similar for the classes in java.sql.
e.g.
package java.sql;
public interface SQLClose {
public void close() throws SQLException;
};
and have all of the interfaces with a close method (nearly all of them) extend the interface.
Thank you.
JUSTIFICATION :
I would like to be able to write a uniform method and call it in my finally blocks. Currently I have to embed multiple try/catch blocks inside my finally blocks to make sure that all io related resources are closed. Or I have to have multiple methods for each object, and it's absolutely senseless.
Adding this interface and having the suggested classes implement it would be an additive change. Aside from implementing the additional interface there would be no other changes to the classes mentioned above.
(Incident Review ID: 234221)
======================================================================