博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JDK7中的新特性 The try-with-resources Statement
阅读量:7047 次
发布时间:2019-06-28

本文共 340 字,大约阅读时间需要 1 分钟。

类似于这样的代码

try (         ByteArrayOutputStream bos = new ByteArrayOutputStream();         ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(bos));    ) {      oos.writeUnshared(attributes);      oos.flush();      serialized = bos.toByteArray();    }

简而言之就是不用自己费事写finally啦, 可以避免finally里面再出exception导致try里的exception被覆盖的问题

转载地址:http://nmzol.baihongyu.com/

你可能感兴趣的文章
linux源代码安装软件
查看>>
2013年4月IT技术行业网站综合影响力排名
查看>>
Magento session机制的分析与应用
查看>>
linux 服务器长ping 加时间戳;转
查看>>
http与https的区别
查看>>
一些可以查询IP地理位置、身份证所在地、手机归属地的接口
查看>>
鼠标滚动插件smoovejs和wowjs
查看>>
我的友情链接
查看>>
javascript学习记录-数组(8)-完结 2014/02/26
查看>>
读取通讯录联系人
查看>>
ssh三大框架简单整合,struts2整合JasperReport报表、图表,解决HTML显示图片不出来,PDF中文不显示的问题...
查看>>
XML基础知识
查看>>
telnet: Unable to connect to remote host: No route to host处理过程
查看>>
我的友情链接
查看>>
单元测试Struts2的Action(包含源码)
查看>>
简要总结最近遇到的5个问题
查看>>
我的友情链接
查看>>
高校专业机房使用VMware Player解决方案
查看>>
我的友情链接
查看>>
Centos Development Tools 安装
查看>>