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
commit 74f3799eb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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