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 SV
2022-07-05 18:32:20 +05:30
committed by GitHub
parent 4cdc309e65
commit 692cef8ebf
@@ -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());
}
}
}
}