Closeable and Socket, ZipFile
iag at ribbit.SFBay.Sun.COM
Fri Jul 6 19:00:59 UTC 2007
> Pascal S. de Kloe wrote:
> > Socket, ServerSocket and ZipFile all have a close() method which closes
> > the respective streams so what's the problem?
> As I said, those classes do not implement the java.io.Closeable interfance.
java.io.Closeable was added semi-late into jdk5.0 to support
java.util.Formatter. In that same release it also became useful for
java.util.Scanner. At that time there was need (and to a certain
extent time) for us to identify those classes which closely interacted
with one of those two features (primarily classes in java.io java.nio,
and java.nio.channels), so that's all that we took care of.
Assuming they follow the specification, it would be perfectly
reasonable for any class to declare that they implement Closeable.
Here's the status for the specific classes mentioned:
6499348: java.net socket classes should implement java.io.Closeable
- fixed in jdk7, b06
4926319: java.util.Scanner needs a close method
- fixed in jdk5.0-beta (b26)
6389768: ZipFile should implement java.io.Closeable
- currently unresolved RFE
More information about the core-libs-dev