jdk1.7引入了资源自动关闭的接口AutoCloseable。一些资源也实现了该接口,如preparedStatement、Connection、InputStream、outputStream等等资源接口。在使用的时候只需要把资源在try块中用小括号括起来就可以了。
|
|
jdk1.7引入了资源自动关闭的接口AutoCloseable。一些资源也实现了该接口,如preparedStatement、Connection、InputStream、outputStream等等资源接口。在使用的时候只需要把资源在try块中用小括号括起来就可以了。
|
|
近期评论