Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf36de03

Browse files
author
Diffblue assistant
committed
Use try-with-resources
Replace try statements that close a resource in the finally block with atry-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
1 parentb642623 commitf36de03

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

‎execute-around/src/main/java/com/iluwatar/execute/around/SimpleFileWriter.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ public class SimpleFileWriter {
3737
* Constructor
3838
*/
3939
publicSimpleFileWriter(Stringfilename,FileWriterActionaction)throwsIOException {
40-
FileWriterwriter =newFileWriter(filename);
41-
try {
40+
try (FileWriterwriter =newFileWriter(filename)) {
4241
action.writeFile(writer);
43-
}finally {
44-
writer.close();
4542
}
4643
}
4744
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp