try with resources in java stream inside a stream 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");
}