mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 10:58:42 +00:00
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:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user