try with resources java example
Example: java try with resources
try (PrintWriter writer = new PrintWriter(new File("test.txt"))) {
writer.println("Hello World");
}
try (PrintWriter writer = new PrintWriter(new File("test.txt"))) {
writer.println("Hello World");
}