test/java/util/Scanner/FailingConstructors.java

Print this page
rev 3509 : 7021209: convert lang, math, util to use try-with-resources
Reviewed-by: XXX

@@ -44,13 +44,13 @@
         test(false, new File(fileName));
 
         /* create the file and write its contents */
         File file = File.createTempFile(fileName, null);
         file.deleteOnExit();
-        FileOutputStream fos = new FileOutputStream(file);
+        try (FileOutputStream fos = new FileOutputStream(file)) {
         fos.write(FILE_CONTENTS.getBytes());
-        fos.close();
+        }
 
         test(true, file);
         file.delete();
     }