Skip to content

Commit 36940b6

Browse files
FileWriterWithEncodingTest: simplify setUp method
1 parent 2341c40 commit 36940b6

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,10 @@ private File getTestDirectory() {
5656
private final char[] anotherTestContent = new char[]{'f', 'z', 'x'};
5757

5858
@Before
59-
public void setUp() {
59+
public void setUp() throws Exception {
6060
final File encodingFinder = new File(getTestDirectory(), "finder.txt");
61-
OutputStreamWriter out = null;
62-
try {
63-
out = new OutputStreamWriter(new FileOutputStream(encodingFinder));
61+
try (OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(encodingFinder))) {
6462
defaultEncoding = out.getEncoding();
65-
} catch (final IOException ex) {
66-
throw new RuntimeException(ex.getMessage());
67-
} finally {
68-
IOUtils.closeQuietly(out);
6963
}
7064
file1 = new File(getTestDirectory(), "testfile1.txt");
7165
file2 = new File(getTestDirectory(), "testfile2.txt");

0 commit comments

Comments
 (0)