5.9 实战:使用try-with-resources

以下示例用于演示Java 7和Java 9中try-with-resources在用法上的差异。

运行程序,控制台输出如下:

   do something
   do other things
   other resource is closed
   some resource is closed
   do something
   do other things
   other resource is closed
   some resource is closed