try resource java close file finally code 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");
}