Gets rid of the nested try-with-resources blocks. Improves legibility slightly.
### Why are the changes needed?
Make the example code just a bit nicer.
### How was this patch tested?
It still compiles. I created a simple (maven) project using only these two java files.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes#7160 from jagij/patch-1.
Closes#7160
9d9624841 [Jan Willem] single try-with-resources blocks
Authored-by: Jan Willem <jan.willem.ps@gmail.com>
Signed-off-by: Cheng Pan <chengpan@apache.org>