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:
		@@ -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();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user