Merge pull request #788 from diffblue-assistant/finallyclosetotrywithresources

Use try-with-resources
This commit is contained in:
Narendra Pathai
2018-08-28 13:17:16 +05:30
committed by GitHub

View File

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