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
*/
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();
}
}
}