// Path: test-automation-framework/org.wso2.carbon.automation.extensions/src/main/java/org/wso2/carbon/automation/extensions/jmeter/util/Utils.java
// public class Utils {
//     public static void copyFromClassPath(String fileName, File destination) throws IOException {
// 
//         BufferedWriter out = null;
//         try {
// 
//              out = new BufferedWriter
//                     (new OutputStreamWriter(new FileOutputStream(destination), Charset.defaultCharset()));
// 
//             IOUtils.copy(Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName), out);
// 
// 
//         } catch (IOException e) {
//             throw new IOException("Could not create temporary saveservice.properties", e);
//         } finally {
//             if (out != null) {
//                 out.flush();
//                 out.close();
//             }
//         }
//     }
// }


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.automation.extensions.jmeter.util.Utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
        //creating jmeter directory
        jMeterHome = new File(targetDir, "jmeter");
        if (!jMeterHome.mkdirs()) {
            log.error("Unable to create jmeter directory");
            throw new RuntimeException("Unable to create jmeter directory");
        }

        reportDir = new File(jMeterHome, "reports");

        // now create lib dir for jmeter fallback mode
        libDir = new File(jMeterHome + File.separator + "lib");
        createLibDirectory(libDir);

        binDir = new File(jMeterHome + File.separator + "bin");
        if (!binDir.exists()) {
            if (!binDir.mkdirs()) {
                log.error("unable to create bin directory");
                throw new RuntimeException("unable to create bin dir for Jmeter");
            }
        }

        //saving properties file in bin directory
        saveServiceProps = new File(binDir, "saveservice.properties");
        upgradeProps = new File(binDir, "upgrade.properties");
        jmeterPropertyFile = new File(binDir, "jmeter.properties");
        jmeterPropertyFileTemp = new File(binDir, "jmeterTemp.properties");


        //copying saveservice.properties from classpath
        try {
// Path: test-automation-framework/org.wso2.carbon.automation.extensions/src/main/java/org/wso2/carbon/automation/extensions/jmeter/util/Utils.java
// public class Utils {
//     public static void copyFromClassPath(String fileName, File destination) throws IOException {
// 
//         BufferedWriter out = null;
//         try {
// 
//              out = new BufferedWriter
//                     (new OutputStreamWriter(new FileOutputStream(destination), Charset.defaultCharset()));
// 
//             IOUtils.copy(Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName), out);
// 
// 
//         } catch (IOException e) {
//             throw new IOException("Could not create temporary saveservice.properties", e);
//         } finally {
//             if (out != null) {
//                 out.flush();
//                 out.close();
//             }
//         }
//     }
// }


// Path: test-automation-framework/org.wso2.carbon.automation.extensions/src/main/java/org/wso2/carbon/automation/extensions/jmeter/JMeterInstallationProvider.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.automation.extensions.jmeter.util.Utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

        //creating jmeter directory
        jMeterHome = new File(targetDir, "jmeter");
        if (!jMeterHome.mkdirs()) {
            log.error("Unable to create jmeter directory");
            throw new RuntimeException("Unable to create jmeter directory");
        }

        reportDir = new File(jMeterHome, "reports");

        // now create lib dir for jmeter fallback mode
        libDir = new File(jMeterHome + File.separator + "lib");
        createLibDirectory(libDir);

        binDir = new File(jMeterHome + File.separator + "bin");
        if (!binDir.exists()) {
            if (!binDir.mkdirs()) {
                log.error("unable to create bin directory");
                throw new RuntimeException("unable to create bin dir for Jmeter");
            }
        }

        //saving properties file in bin directory
        saveServiceProps = new File(binDir, "saveservice.properties");
        upgradeProps = new File(binDir, "upgrade.properties");
        jmeterPropertyFile = new File(binDir, "jmeter.properties");
        jmeterPropertyFileTemp = new File(binDir, "jmeterTemp.properties");


        //copying saveservice.properties from classpath
        try {
            Utils.copyFromClassPath("bin/saveservice.properties", saveServiceProps);