Skip to content

Commit

Permalink
fix: Surrounded with try with resources (iluwatar#1983)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohana Rao S V <[email protected]>
  • Loading branch information
mohanaraosv and mohanraosv authored Jul 5, 2022
1 parent 4cdc309 commit 692cef8
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ public static void main(String[] args) throws IOException {
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());
}
}
}
}

0 comments on commit 692cef8

Please sign in to comment.