Example usage for java.util Properties load

List of usage examples for java.util Properties load

Introduction

In this page you can find the example usage for java.util Properties load.

Prototype

public synchronized void load(InputStream inStream) throws IOException 

Source Link

Document

Reads a property list (key and element pairs) from the input byte stream.

Usage

From source file:com.ipcglobal.awscdh.config.ManageCluster.java

/**
 * The main method.//from  w  w  w .j  a v a  2 s .  c om
 *
 * @param args the arguments
 * @throws Exception the exception
 */
public static void main(String[] args) throws Exception {
    try {
        long before = System.currentTimeMillis();
        LogTool.initConsole();
        if (args.length <= 1)
            throw new Exception(
                    "Action and Properties file name are required parameter - format: start|stop example.properties");
        String action = args[0];
        log.info("Begin: action=" + action);
        Properties properties = new Properties();
        properties.load(new FileInputStream(args[1]));
        ManageEc2 manageEc2 = new ManageEc2(properties);
        ManageCdh manageCdh = new ManageCdh(properties);

        if ("start".equals(action)) {
            manageEc2.start();
            manageCdh.start();
        } else if ("stop".equals(action)) {
            manageCdh.stop();
            manageEc2.stop();
        } else
            throw new Exception("Invalid action: " + action + ", must be start or stop");

        log.info("Complete: action=" + action + ", elapsed "
                + Utils.convertMSecsToHMmSs(System.currentTimeMillis() - before));

    } catch (Exception e) {
        log.error(e);
        e.printStackTrace();
    }
}

From source file:com.mobius.software.mqtt.performance.controller.ControllerRunner.java

public static void main(String[] args) {
    try {//from   w  ww  .jav  a 2 s  .  co m
        /*URI baseURI = URI.create(args[0].replace("-baseURI=", ""));
        configFile = args[1].replace("-configFile=", "");*/
        String userDir = System.getProperty("user.dir");
        System.out.println("user.dir: " + userDir);
        setConfigFilePath(userDir + "/config.properties");
        Properties prop = new Properties();
        prop.load(new FileInputStream(configFile));
        System.out.println("properties loaded...");

        String hostname = prop.getProperty("hostname");
        Integer port = Integer.parseInt(prop.getProperty("port"));
        URI baseURI = new URI(null, null, hostname, port, null, null, null);

        configureConsoleLogger();
        System.out.println("starting http server...");
        JerseyServer server = new JerseyServer(baseURI);
        System.out.println("http server started");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("press any key to stop: ");
        br.readLine();
        server.terminate();
    } catch (Throwable e) {
        logger.error("AN ERROR OCCURED: " + e.getMessage());
        e.printStackTrace();
    } finally {
        System.exit(0);
    }
}

From source file:com.retroduction.carma.application.Carma.java

/**
 * command line test runner, reads configuration from mutationconfig.xml
 * /*from  w  w w  .j a v  a  2 s.  co  m*/
 * @throws ParseException
 * @throws IOException
 */
public static void main(String[] args) throws ParseException {

    CommandLine line = new CLIValidator().readCLI(args);

    File customPropertiesFile;
    if (line.hasOption(CLIValidator.USER_CONFIG_OPTION_SHORT)) {
        customPropertiesFile = new File(line.getOptionValue(CLIValidator.USER_CONFIG_OPTION_SHORT));
    } else {
        customPropertiesFile = new File(DEFAULT_USER_CONFIG);
    }

    CarmaDriverSetup setup = new CarmaDriverSetup();

    Properties customProps = new Properties();
    try {
        customProps.load(new FileInputStream(customPropertiesFile));

    } catch (IOException e) {
        throw new CarmaException("Failed to load configuration", e);
    }
    setup.addCustomConfiguration(customProps);
    Core driver = setup.getDriver();
    driver.execute();

}

From source file:com.shuzhilian.icu.license.LicenseGenerator.java

public static void main(String[] args) throws IOException, ParseException {
    if (args.length != 6) {
        System.out.println(/*from  ww w.j  ava  2 s .  c om*/
                "Args: propties_file license_path license_name license_password private_key_file private_key_password");
        return;
    }
    String prop = args[0];
    String path = args[1];
    String name = args[2];
    String pawd = args[3];
    String pk = args[4];
    String pkpd = args[5];

    LicenseGenerator generator = new LicenseGenerator();
    generator.startUp(new File(pk), pkpd.toCharArray());

    Properties conf = new Properties();
    conf.load(new FileInputStream(new File(prop)));
    generator.generateLicense(path, name, pawd.toCharArray(), conf);
}

From source file:Main.java

  public static void main(String[] args) throws Exception {
  Properties prop = new Properties();
  String fileName = "app.config";
  InputStream is = new FileInputStream(fileName);

  prop.load(is);

  System.out.println(prop.getProperty("app.name"));
  System.out.println(prop.getProperty("app.version"));

  System.out.println(prop.getProperty("app.vendor", "Java"));
}

From source file:com.gvmax.web.WebMain.java

@SuppressWarnings("deprecation")
public static void main(String[] args) {
    try {// www  . ja  va2s. c  om
        MetricRegistry registry = MetricsUtil.getRegistry();
        Properties props = new Properties();
        props.load(new ClassPathResource("/web.properties").getInputStream());

        int httpPort = Integer.parseInt(props.getProperty("web.http.port", "19080"));
        int httpsPort = Integer.parseInt(props.getProperty("web.https.port", "19443"));
        logger.info("Starting server: " + httpPort + " :: " + httpsPort);

        Server server = new Server(httpPort);
        ThreadPool threadPool = new InstrumentedQueuedThreadPool(registry);
        server.setThreadPool(threadPool);

        // Setup HTTPS
        if (new File("gvmax.jks").exists()) {
            SslSocketConnector connector = new SslSocketConnector();
            connector.setPort(httpsPort);
            connector.setKeyPassword(props.getProperty("web.keystore.password"));
            connector.setKeystore("gvmax.jks");
            server.addConnector(connector);
        } else {
            logger.warn("keystore gvmax.jks not found, ssl disabled");
        }

        // Setup WEBAPP
        URL warUrl = WebMain.class.getClassLoader().getResource("webapp");
        String warUrlString = warUrl.toExternalForm();
        WebAppContext ctx = new WebAppContext(warUrlString, "/");
        ctx.setAttribute(MetricsServlet.METRICS_REGISTRY, registry);
        InstrumentedHandler handler = new InstrumentedHandler(registry, ctx);
        server.setHandler(handler);
        server.start();
        server.join();
    } catch (Exception e) {
        logger.error(e);
        System.exit(0);
    }
}

From source file:Main.java

public static void main(String[] a) throws Exception {
    Properties p = new Properties();
    URL url = ClassLoader.getSystemResource("/com/java2s/config/system.props");
    if (url != null)
        p.load(url.openStream());

}

From source file:com.gnizr.core.delicious.DeliciousImportApp.java

/**
 * @param args//from  w w w . j  av  a 2 s . c o  m
 */
public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.out.println("Missing required arguments.");
        System.exit(1);
    }
    Properties prpt = new Properties();
    prpt.load(new FileInputStream(args[0]));
    String dbdrv = prpt.getProperty("gnizr.db.driver");
    String dbUrl = prpt.getProperty("gnizr.db.url");
    String dbUser = prpt.getProperty("gnizr.db.username");
    String dbPass = prpt.getProperty("gnizr.db.password");
    String gnizrUser = prpt.getProperty("gnizr.import.user");
    String gnizrPassword = prpt.getProperty("gnizr.import.password");
    String gnizrEmail = prpt.getProperty("gnizr.import.email");
    String gnizrFullname = prpt.getProperty("gnizr.import.fullname");
    String deliUser = prpt.getProperty("gnizr.import.delicious.user");
    String deliPassword = prpt.getProperty("gnizr.import.delicious.password");

    BasicDataSource datasource = new BasicDataSource();
    datasource.setDriverClassName(dbdrv);
    datasource.setUrl(dbUrl);
    datasource.setUsername(dbUser);
    datasource.setPassword(dbPass);

    GnizrDao gnizrDao = GnizrDao.getInstance(datasource);

    UserManager userManager = new UserManager(gnizrDao);
    BookmarkManager bookmarkManager = new BookmarkManager(gnizrDao);
    FolderManager folderManager = new FolderManager(gnizrDao);

    User gUser = new User();
    gUser.setUsername(gnizrUser);
    gUser.setPassword(gnizrPassword);
    gUser.setFullname(gnizrFullname);
    gUser.setEmail(gnizrEmail);
    gUser.setAccountStatus(AccountStatus.ACTIVE);
    gUser.setCreatedOn(GnizrDaoUtil.getNow());

    DeliciousImport deliciousImport = new DeliciousImport(deliUser, deliPassword, gUser, userManager,
            bookmarkManager, folderManager, true);
    ImportStatus status = deliciousImport.doImport();
    System.out.println("Del.icio.us Import Status: ");
    System.out.println("- total number: " + status.getTotalNumber());
    System.out.println("- number added: " + status.getNumberAdded());
    System.out.println("- number updated: " + status.getNumberUpdated());
    System.out.println("- number failed: " + status.getNumberError());
}

From source file:com.sun.labs.aura.grid.ec2.Ec2Sample.java

public static void main(String[] args) throws Exception {
    Properties props = new Properties();
    props.load(Ec2Sample.class.getResourceAsStream("aws.properties"));
    Jec2 ec2 = new Jec2(props.getProperty("aws.accessId"), props.getProperty("aws.secretKey"));

    List<String> params = new ArrayList<String>();
    List<ImageDescription> images = ec2.describeImages(params);
    System.out.println(String.format("%d available images", images.size()));
    for (ImageDescription img : images) {
        if (img.getImageState().equals("available")) {
            System.out.println(img.getImageId() + "\t" + img.getImageLocation() + "\t" + img.getImageOwnerId());
        }/*from  ww w  . j  a va2s .co  m*/
    }

    // describe instances
    params = new ArrayList<String>();
    List<ReservationDescription> instances = ec2.describeInstances(params);
    System.out.println(String.format("%d instances", instances.size()));
    String instanceId = null;
    for (ReservationDescription res : instances) {
        System.out.println(res.getOwner() + "\t" + res.getReservationId());
        if (res.getInstances() != null) {
            for (Instance inst : res.getInstances()) {
                System.out.println("\t" + inst.getImageId() + "\t" + inst.getDnsName() + "\t" + inst.getState()
                        + "\t" + inst.getKeyName());
                instanceId = inst.getInstanceId();
            }
        }
    }

    // test console output
    if (instanceId != null) {
        ConsoleOutput consOutput = ec2.getConsoleOutput(instanceId);
        System.out.println("Console Output:");
        System.out.println(consOutput.getOutput());
    }

    // show keypairs
    List<KeyPairInfo> info = ec2.describeKeyPairs(new String[] {});
    System.out.println("keypair list");
    for (KeyPairInfo i : info) {
        System.out.println("keypair : " + i.getKeyName() + ", " + i.getKeyFingerprint());
    }
}

From source file:com.imolinfo.offline.CrossFoldValidation.java

public static void main(String[] args)
        throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {

    Properties p = new Properties();
    p.load(new FileInputStream("runtime.properties"));
    GlobalVariable.getInstance().setProperties(p);
    String classificatorName = Class.forName(p.getProperty("ClassificationModel")).newInstance().toString();

    SparkConf conf = new SparkConf().setAppName("CrossFoldValidation: " + classificatorName);
    final JavaSparkContext jsc = new JavaSparkContext(conf);

    invokePipeline(jsc);/*from   www .j  a v  a 2  s . c  om*/
}