re base code
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / utils / rest / AutomationUtils.java
index 65ab6c9..8d39bd1 100644 (file)
 
 package org.openecomp.sdc.ci.tests.utils.rest;
 
+import org.openecomp.sdc.ci.tests.config.Config;
+import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+import org.openecomp.sdc.ci.tests.utils.Utils;
+
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 
-import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-
 public class AutomationUtils extends BaseRestUtils {
        
        
@@ -63,24 +63,24 @@ public class AutomationUtils extends BaseRestUtils {
        
        public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName) throws IOException {
                File myFoo = new File(filepath);
-               FileOutputStream fooStream = new FileOutputStream(myFoo, false); // true to append
-               String versions =  ("onboardVersion=\""+ onboardVersion+ "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n");
-               byte[] myBytes = versions.getBytes();
-               fooStream.write(myBytes);
-               fooStream.close();
+               try (FileOutputStream fooStream = new FileOutputStream(myFoo, false)) {
+                       String versions = ("onboardVersion=\"" + onboardVersion + "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\"" + envData + "\"\n" + "suiteName=\"" + suiteName + "\"\n");
+                       byte[] myBytes = versions.getBytes();
+                       fooStream.write(myBytes);
+               }
        }
 
        public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName, String reportStartTime) throws IOException {
                File myFoo = new File(filepath);
-               FileOutputStream fooStream = new FileOutputStream(myFoo, false); // true to append
-               String versions =  ("onboardVersion=\""+ onboardVersion+ "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n" + "reportStartTime=\""+ reportStartTime+ "\"\n");
-               byte[] myBytes = versions.getBytes();
-               fooStream.write(myBytes);
-               fooStream.close();
+               try (FileOutputStream fooStream = new FileOutputStream(myFoo, false)) {
+                       String versions = ("onboardVersion=\"" + onboardVersion + "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\"" + envData + "\"\n" + "suiteName=\"" + suiteName + "\"\n" + "reportStartTime=\"" + reportStartTime + "\"\n");
+                       byte[] myBytes = versions.getBytes();
+                       fooStream.write(myBytes);
+               }
        }
        
        public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData)
-                       throws FileNotFoundException, IOException {
+                       throws IOException {
                createVersionsInfoFile(filepath, onboardVersion, osVersion, envData, null);
        }