mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-13 12:14:51 +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:
1 parent
4cdc309e65
commit
692cef8ebf
1 file changed
+4
-3
@@ -53,9 +53,10 @@ public class App {
|
|||||||
new SimpleFileWriter("testfile.txt", writeHello);
|
new SimpleFileWriter("testfile.txt", writeHello);
|
||||||
|
|
||||||
// print the file contents
|
// print the file contents
|
||||||
var scanner = new Scanner(new File("testfile.txt"));
|
try (var scanner = new Scanner(new File("testfile.txt"))) {
|
||||||
while (scanner.hasNextLine()) {
|
while (scanner.hasNextLine()) {
|
||||||
LOGGER.info(scanner.nextLine());
|
LOGGER.info(scanner.nextLine());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user