< prev index next >

test/hotspot/jtreg/runtime/appcds/MultiReleaseJars.java

Print this page

@@ -70,17 +70,18 @@
 
     static void writeFile(File file, String... contents) throws Exception {
         if (contents == null) {
             throw new java.lang.RuntimeException("No input for writing to file" + file);
         }
+        try (
         FileOutputStream fos = new FileOutputStream(file);
-        PrintStream ps = new PrintStream(fos);
+             PrintStream ps = new PrintStream(fos)
+        ) {
         for (String str : contents) {
             ps.println(str);
         }
-        ps.close();
-        fos.close();
+        }
     }
 
     /* version.jar entries and files:
      * META-INF/
      * META-INF/MANIFEST.MF
< prev index next >