Skip to content

Commit 74f3799

Browse files
authored
Merge pull request iluwatar#788 from diffblue-assistant/finallyclosetotrywithresources
Use try-with-resources
2 parents b642623 + f36de03 commit 74f3799

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

execute-around/src/main/java/com/iluwatar/execute/around/SimpleFileWriter.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ public class SimpleFileWriter {
3737
* Constructor
3838
*/
3939
public SimpleFileWriter(String filename, FileWriterAction action) throws IOException {
40-
FileWriter writer = new FileWriter(filename);
41-
try {
40+
try (FileWriter writer = new FileWriter(filename)) {
4241
action.writeFile(writer);
43-
} finally {
44-
writer.close();
4542
}
4643
}
4744
}

0 commit comments

Comments
 (0)