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
This commit is contained in:
Diffblue assistant 2018-08-23 11:28:17 +01:00
parent b64262303a
commit f36de036f6

View File

@ -37,11 +37,8 @@ public class SimpleFileWriter {
* Constructor
*/
public SimpleFileWriter(String filename, FileWriterAction action) throws IOException {
FileWriter writer = new FileWriter(filename);
try {
try (FileWriter writer = new FileWriter(filename)) {
action.writeFile(writer);
} finally {
writer.close();
}
}
}