fix: Surrounded with try with resources (#1983)

Co-authored-by: Mohana Rao S V <mohana.rao.s.v@tietoevry.com>
This commit is contained in:
MohanaRao SVandMohana Rao S V authored and GitHub committed 2022-07-05 16:02:20 +03:00
1 parent 4cdc309e65
commit 692cef8ebf
1 file changed
+4 -3
@@ -53,9 +53,10 @@ public class App {
new SimpleFileWriter("testfile.txt", writeHello);
// print the file contents
var scanner = new Scanner(new File("testfile.txt"));
while (scanner.hasNextLine()) {
LOGGER.info(scanner.nextLine());
try (var scanner = new Scanner(new File("testfile.txt"))) {
while (scanner.hasNextLine()) {
LOGGER.info(scanner.nextLine());
}
}
}
}