All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qa.framework.generator.PropertiesSetting Maven / Gradle / Ivy

There is a newer version: 3.8
Show newest version
package com.qa.framework.generator;

import com.qa.framework.library.base.StringHelper;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Properties;

public class PropertiesSetting {

    /**
     * @param args the input arguments
     */
    public static void main(String[] args) {
        autoSetting(args);
    }

    public static void autoSetting(String[] args) {
        String path = null;
        if (System.getProperty("basedir") != null) {
            path = System.getProperty("basedir");
        } else {
            path = System.getProperty("user.dir");
        }
        final File propsFile = new File(path + File.separator, "config.properties");
        Properties props = new Properties();
        try {
            props.load(new FileInputStream(propsFile));
            for (String arg : args) {
                if (arg.contains("=")) {
                    List argList = StringHelper.getTokensList(arg, "=");
                    props.put(argList.get(0), argList.get(1));
                }
            }
            props.store(new FileOutputStream(propsFile), "");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy