Skip to content

Commit f36de03

Browse files
author
Diffblue assistant
committed
Use try-with-resources
Replace try statements that close a resource in the finally block with a try-with-resources statement [1]. This commit was created automatically by Diffblue refactorings (https://www.diffblue.com/). [1] https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
1 parent b642623 commit f36de03

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)