jdk7可以用 thy-with-resoucese, 不用手动关闭
查询资料都说要实现autoclouseable接口才能自动关闭流 ,但自测了多次,不管是否测试aoutocloeseable中的close()方法都可以自动关闭
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
try( BufferedWriter write= new BufferedWriter(new FileWriter("E:\testAutoCloseable.txt"))){ write.write("自动关闭"); System.out.println(1111); } catch (IOException e) { e.printStackTrace(); }