@@ -1645,26 +1645,17 @@ public void testIsFileNewerOlder() throws Exception {
16451645 throw new IOException ("Cannot create file " + oldFile
16461646 + " as the parent directory does not exist" );
16471647 }
1648- final OutputStream output1 =
1649- new BufferedOutputStream (Files .newOutputStream (oldFile .toPath ()));
1650- try {
1648+ try (final OutputStream output1 = new BufferedOutputStream (Files .newOutputStream (oldFile .toPath ()))) {
16511649 TestUtils .generateTestData (output1 , 0 );
1652- } finally {
1653- IOUtils .closeQuietly (output1 );
16541650 }
16551651
16561652 do {
16571653 TestUtils .sleepQuietly (1000 );
16581654 if (!reference .getParentFile ().exists ()) {
1659- throw new IOException ("Cannot create file " + reference
1660- + " as the parent directory does not exist" );
1655+ throw new IOException ("Cannot create file " + reference + " as the parent directory does not exist" );
16611656 }
1662- final OutputStream output =
1663- new BufferedOutputStream (Files .newOutputStream (reference .toPath ()));
1664- try {
1657+ try (final OutputStream output = new BufferedOutputStream (Files .newOutputStream (reference .toPath ()))) {
16651658 TestUtils .generateTestData (output , 0 );
1666- } finally {
1667- IOUtils .closeQuietly (output );
16681659 }
16691660 } while (getLastModifiedMillis (oldFile ) == getLastModifiedMillis (reference ));
16701661
@@ -1689,12 +1680,8 @@ public void testIsFileNewerOlder() throws Exception {
16891680 throw new IOException ("Cannot create file " + newFile
16901681 + " as the parent directory does not exist" );
16911682 }
1692- final OutputStream output =
1693- new BufferedOutputStream (Files .newOutputStream (newFile .toPath ()));
1694- try {
1683+ try (final OutputStream output = new BufferedOutputStream (Files .newOutputStream (newFile .toPath ()))) {
16951684 TestUtils .generateTestData (output , 0 );
1696- } finally {
1697- IOUtils .closeQuietly (output );
16981685 }
16991686 } while (getLastModifiedMillis (reference ) == getLastModifiedMillis (newFile ));
17001687
@@ -2353,22 +2340,15 @@ public void testMoveFileToDirectory_Errors() throws Exception {
23532340 final File testFile1 = new File (tempDirFile , "testMoveFileFile1" );
23542341 final File testFile2 = new File (tempDirFile , "testMoveFileFile2" );
23552342 if (!testFile1 .getParentFile ().exists ()) {
2356- throw new IOException ("Cannot create file " + testFile1
2357- + " as the parent directory does not exist" );
2343+ throw new IOException ("Cannot create file " + testFile1 + " as the parent directory does not exist" );
23582344 }
2359- final BufferedOutputStream output1 =
2360- new BufferedOutputStream (Files .newOutputStream (testFile1 .toPath ()));
2361- try {
2345+ try (final BufferedOutputStream output1 = new BufferedOutputStream (Files .newOutputStream (testFile1 .toPath ()))) {
23622346 TestUtils .generateTestData (output1 , 0 );
2363- } finally {
2364- IOUtils .closeQuietly (output1 );
23652347 }
23662348 if (!testFile2 .getParentFile ().exists ()) {
2367- throw new IOException ("Cannot create file " + testFile2
2368- + " as the parent directory does not exist" );
2349+ throw new IOException ("Cannot create file " + testFile2 + " as the parent directory does not exist" );
23692350 }
2370- final BufferedOutputStream output =
2371- new BufferedOutputStream (Files .newOutputStream (testFile2 .toPath ()));
2351+ final BufferedOutputStream output = new BufferedOutputStream (Files .newOutputStream (testFile2 .toPath ()));
23722352 try {
23732353 TestUtils .generateTestData (output , 0 );
23742354 } finally {
0 commit comments