Check out example codes for "java try with resources". It will help you in understanding the concepts better.

Code Example 1

try (PrintWriter writer = new PrintWriter(new File("test.txt"))) {
  writer.println("Hello World");
}

Learn ReactJs, React Native from akashmittal.com