To minimize boilerplate code, I’d like to have a Socket and ServerSocket class which both implement the Closeable interface.
I’ve seen that in Java 7, Socket and ServerSocket are likely to implement Closeable, so can’t I just do something like:
public class ClosableSocket extends Socket implements Closeable {}
and implement the needed constructors? Or are there better solutions? What I want is to use it in conjunction with Apache Commons IO IOUtil.closeQuietly(Closeable closeable).
I would have something like