Merge pull request #788 from diffblue-assistant/finallyclosetotrywithresources
Use try-with-resources
This commit is contained in:
commit
74f3799eb4
@ -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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user