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:edu.indiana.d2i.htrc.corpus.analysis.LDAAnalysisDriver.java

public static void main(String[] args) throws Exception {

    GenericOptionsParser parser = new GenericOptionsParser(new Configuration(), args);

    CommandLine commandLine = parser.getCommandLine();

    Option[] options = commandLine.getOptions();

    /**//from  w  ww.  j av a 2 s. c o m
     * appArgs[0] = <path/to/input/directory> (where sequence files reside)
     * appArgs[1] = <path/to/output/directory/prefix> (where LDA state file
     * should go) appArgs[2] = <path/local/property/file>
     * 
     * Note: the passed in <path/to/output/directory/prefix> is only a
     * prefix, we automatically append the iteration number suffix
     */
    String[] appArgs = parser.getRemainingArgs();

    // load property file
    Properties prop = new Properties();
    prop.load(new FileInputStream(appArgs[2]));

    int maxIterationNum = Integer.parseInt(
            prop.getProperty(Constants.LDA_ANALYSIS_MAX_ITER, Constants.LDA_ANALYSIS_DEFAULT_MAX_ITER));

    int iterationCount = 0;

    /**
     * in the first iteration (iteration 0), there is no LDA state
     */
    String[] arguments = generateArgs(options, new String[0], appArgs[0],
            appArgs[1] + "-iter-" + iterationCount);

    /**
     * iterate until convergence or maximum iteration number reached
     */
    while (true) {

        int exitCode = ToolRunner.run(new LDAAnalysisDriver(), arguments);

        System.out.println(String.format("LDA analysis finished iteration %d, with exitCode = %d",
                iterationCount, exitCode));

        /**
         * LDA state is the output (sequence file) from current iteration
         * and is used to initialize the words-topics table and
         * topics-documents table for the next iteration
         */
        String ldaStateFilePath = appArgs[1] + "-iter-" + iterationCount + File.separator + "part-r-00000";

        /**
         * load LDA state to check whether it is converged
         */
        if (isAnalysisConverged(ldaStateFilePath)) {
            System.out.println(String.format("LDA analysis converged at iteration %d", iterationCount));
            break;
        }

        if ((iterationCount + 1) >= maxIterationNum) {
            System.out.println(String.format(
                    "LDA analysis reached the maximum iteration number %d, going to stop", maxIterationNum));
            break;
        }

        String[] otherOps = { "-D", "user.args.lda.state.filepath=" + ldaStateFilePath };

        /**
         * generate arguments for the next iteration and increase iteration
         * count
         */
        arguments = generateArgs(options, otherOps, appArgs[0], appArgs[1] + "-iter-" + ++iterationCount);
    }

}

From source file:azkaban.jobtype.HadoopSecureHiveWrapper.java

public static void main(final String[] args) throws Exception {

    String propsFile = System.getenv(ProcessJob.JOB_PROP_ENV);
    Properties prop = new Properties();
    prop.load(new BufferedReader(new FileReader(propsFile)));

    hiveScript = prop.getProperty("hive.script");

    final Configuration conf = new Configuration();

    UserGroupInformation.setConfiguration(conf);
    securityEnabled = UserGroupInformation.isSecurityEnabled();

    if (shouldProxy(prop)) {
        UserGroupInformation proxyUser = null;
        String userToProxy = prop.getProperty("user.to.proxy");
        if (securityEnabled) {
            String filelocation = System.getenv(UserGroupInformation.HADOOP_TOKEN_FILE_LOCATION);
            if (filelocation == null) {
                throw new RuntimeException("hadoop token information not set.");
            }//from   w  w  w .  ja v  a 2 s  .  c o m
            if (!new File(filelocation).exists()) {
                throw new RuntimeException("hadoop token file doesn't exist.");
            }

            logger.info("Found token file " + filelocation);

            logger.info("Setting " + HadoopSecurityManager.MAPREDUCE_JOB_CREDENTIALS_BINARY + " to "
                    + filelocation);
            System.setProperty(HadoopSecurityManager.MAPREDUCE_JOB_CREDENTIALS_BINARY, filelocation);

            UserGroupInformation loginUser = null;

            loginUser = UserGroupInformation.getLoginUser();
            logger.info("Current logged in user is " + loginUser.getUserName());

            logger.info("Creating proxy user.");
            proxyUser = UserGroupInformation.createProxyUser(userToProxy, loginUser);

            for (Token<?> token : loginUser.getTokens()) {
                proxyUser.addToken(token);
            }
        } else {
            proxyUser = UserGroupInformation.createRemoteUser(userToProxy);
        }

        logger.info("Proxied as user " + userToProxy);

        proxyUser.doAs(new PrivilegedExceptionAction<Void>() {
            @Override
            public Void run() throws Exception {
                runHive(args);
                return null;
            }
        });

    } else {
        logger.info("Not proxying. ");
        runHive(args);
    }
}

From source file:de.zazaz.iot.bosch.indego.util.IndegoIftttAdapter.java

public static void main(String[] args) {
    System.setProperty("log4j.configurationFile", "log4j2-indegoIftttAdapter-normal.xml");

    Options options = new Options();

    StringBuilder commandList = new StringBuilder();
    for (DeviceCommand cmd : DeviceCommand.values()) {
        if (commandList.length() > 0) {
            commandList.append(", ");
        }/*from   w  w  w.ja va  2  s. com*/
        commandList.append(cmd.toString());
    }

    options.addOption(Option //
            .builder("c") //
            .longOpt("config") //
            .desc("The configuration file to use") //
            .required() //
            .hasArg() //
            .build());
    options.addOption(Option //
            .builder("d") //
            .longOpt("debug") //
            .desc("Logs more details") //
            .build());
    options.addOption(Option //
            .builder("?") //
            .longOpt("help") //
            .desc("Prints this help") //
            .build());

    CommandLineParser parser = new DefaultParser();
    CommandLine cmds = null;
    try {
        cmds = parser.parse(options, args);
    } catch (ParseException ex) {
        System.err.println(ex.getMessage());
        System.err.println();
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(IndegoIftttAdapter.class.getName(), options);
        System.exit(1);
        return;
    }

    if (cmds.hasOption("?")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(CmdLineTool.class.getName(), options);
        return;
    }

    if (cmds.hasOption("d")) {
        System.setProperty("log4j.configurationFile", "log4j2-indegoIftttAdapter-debug.xml");
    }

    String configFileName = cmds.getOptionValue('c');
    File configFile = new File(configFileName);

    if (!configFile.exists()) {
        System.err.println(String.format("The specified config file (%s) does not exist", configFileName));
        System.err.println();
        System.exit(2);
        return;
    }

    Properties properties = new Properties();
    try (InputStream in = new FileInputStream(configFile)) {
        properties.load(in);
    } catch (IOException ex) {
        System.err.println(ex.getMessage());
        System.err.println(String.format("Was not able to load the properties file (%s)", configFileName));
        System.err.println();
    }

    IftttIndegoAdapterConfiguration config = new IftttIndegoAdapterConfiguration();
    config.setIftttMakerKey(properties.getProperty("indego.ifttt.maker.key"));
    config.setIftttIgnoreServerCertificate(
            Integer.parseInt(properties.getProperty("indego.ifttt.maker.ignore-server-certificate")) != 0);
    config.setIftttReceiverPort(Integer.parseInt(properties.getProperty("indego.ifttt.maker.receiver-port")));
    config.setIftttReceiverSecret(properties.getProperty("indego.ifttt.maker.receiver-secret"));
    config.setIftttOfflineEventName(properties.getProperty("indego.ifttt.maker.eventname-offline"));
    config.setIftttOnlineEventName(properties.getProperty("indego.ifttt.maker.eventname-online"));
    config.setIftttErrorEventName(properties.getProperty("indego.ifttt.maker.eventname-error"));
    config.setIftttErrorClearedEventName(properties.getProperty("indego.ifttt.maker.eventname-error-cleared"));
    config.setIftttStateChangeEventName(properties.getProperty("indego.ifttt.maker.eventname-state-change"));
    config.setIndegoBaseUrl(properties.getProperty("indego.ifttt.device.base-url"));
    config.setIndegoUsername(properties.getProperty("indego.ifttt.device.username"));
    config.setIndegoPassword(properties.getProperty("indego.ifttt.device.password"));
    config.setPollingIntervalMs(Integer.parseInt(properties.getProperty("indego.ifttt.polling-interval-ms")));

    IftttIndegoAdapter adapter = new IftttIndegoAdapter(config);
    adapter.startup();
}

From source file:main.java.com.google.api.services.samples.youtube.cmdline.YouTubeSample.java

public static void main(String[] args) throws IOException {

    Properties properties = new Properties();
    try {/* w  ww.j  a v a  2s.c  o  m*/
        InputStream in = YouTubeSample.class.getResourceAsStream("" + PROPERTIES_FILENAME);
        properties.load(in);

    } catch (IOException e) {
        System.err.println("There was an error reading " + PROPERTIES_FILENAME + ": " + e.getCause() + " : "
                + e.getMessage());
        System.exit(1);
    }

    youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, new HttpRequestInitializer() {

        @Override
        public void initialize(HttpRequest arg0) throws IOException {
            // TODO Auto-generated method stub

        }
    }).setApplicationName("youtubeTest").build();

    YouTube.Videos.List videos = youtube.videos().list("snippet");

    String apiKey = properties.getProperty("youtube.apikey");
    videos.setKey(apiKey);
    videos.setMaxResults(NUMBER_OF_VIDEOS_RETURNED);
    videos.setChart("mostPopular");

    VideoListResponse response = videos.execute();

    java.util.List<Video> videoList = response.getItems();

    if (videoList != null) {
        prettyPrint(videoList.iterator());
    } else {
        System.out.println("There were  no results!");
    }

}

From source file:Main.java

public static void main(String args[]) throws Exception {
    Properties props = new Properties();

    props = new java.util.Properties();
    String path = new Main().getClass().getProtectionDomain().getCodeSource().getLocation().toString()
            .substring(6);//from  ww  w. j  a  v a2s .  c  o  m
    FileInputStream fis = new FileInputStream(new File(path + "\\myprops.props"));
    props.load(fis);
    System.out.println(props);

}

From source file:com.mockey.runner.JettyRunner.java

public static void main(String[] args) throws Exception {
    if (args == null)
        args = new String[0];

    // Initialize the argument parser
    SimpleJSAP jsap = new SimpleJSAP("java -jar Mockey.jar", "Starts a Jetty server running Mockey");
    jsap.registerParameter(new FlaggedOption(ARG_PORT, JSAP.INTEGER_PARSER, "8080", JSAP.NOT_REQUIRED, 'p',
            ARG_PORT, "port to run Jetty on"));
    jsap.registerParameter(new FlaggedOption(BSC.FILE, JSAP.STRING_PARSER,
            MockeyXmlFileManager.MOCK_SERVICE_DEFINITION, JSAP.NOT_REQUIRED, 'f', BSC.FILE,
            "Relative path to a mockey-definitions file to initialize Mockey, relative to where you're starting Mockey"));

    jsap.registerParameter(new FlaggedOption(BSC.URL, JSAP.STRING_PARSER, "", JSAP.NOT_REQUIRED, 'u', BSC.URL,
            "URL to a mockey-definitions file to initialize Mockey"));

    jsap.registerParameter(new FlaggedOption(BSC.TRANSIENT, JSAP.BOOLEAN_PARSER, "true", JSAP.NOT_REQUIRED, 't',
            BSC.TRANSIENT, "Read only mode if set to true, no updates are made to the file system."));

    jsap.registerParameter(new FlaggedOption(BSC.FILTERTAG, JSAP.STRING_PARSER, "", JSAP.NOT_REQUIRED, 'F',
            BSC.FILTERTAG,/*from   www .  ja  v  a2  s .c o m*/
            "Filter tag for services and scenarios, useful for 'only use information with this tag'. "));
    jsap.registerParameter(
            new Switch(ARG_QUIET, 'q', "quiet", "Runs in quiet mode and does not loads the browser"));

    jsap.registerParameter(new FlaggedOption(BSC.HEADLESS, JSAP.BOOLEAN_PARSER, "false", JSAP.NOT_REQUIRED, 'H',
            BSC.HEADLESS,
            "Headless flag. Default is 'false'. Set to 'true' if you do not want Mockey to spawn a browser thread upon startup."));

    // parse the command line options
    JSAPResult config = jsap.parse(args);

    // Bail out if they asked for the --help
    if (jsap.messagePrinted()) {
        System.exit(1);
    }

    // Construct the new arguments for jetty-runner
    int port = config.getInt(ARG_PORT);
    boolean transientState = true;
    // We can add more things to the quite mode. For now we are just not launching browser
    boolean isQuiteMode = false;

    try {
        transientState = config.getBoolean(BSC.TRANSIENT);
        isQuiteMode = config.getBoolean(ARG_QUIET);
    } catch (Exception e) {
        //
    }

    // Initialize Log4J file roller appender.
    StartUpServlet.getDebugFile();
    InputStream log4jInputStream = Thread.currentThread().getContextClassLoader()
            .getResourceAsStream("WEB-INF/log4j.properties");
    Properties log4JProperties = new Properties();
    log4JProperties.load(log4jInputStream);
    PropertyConfigurator.configure(log4JProperties);

    Server server = new Server(port);

    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath("/");
    webapp.setConfigurations(new Configuration[] { new PreCompiledJspConfiguration() });

    ClassPathResourceHandler resourceHandler = new ClassPathResourceHandler();
    resourceHandler.setContextPath("/");

    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.addHandler(resourceHandler);

    contexts.addHandler(webapp);

    server.setHandler(contexts);

    server.start();
    // Construct the arguments for Mockey
    String file = String.valueOf(config.getString(BSC.FILE));
    String url = String.valueOf(config.getString(BSC.URL));
    String filterTag = config.getString(BSC.FILTERTAG);
    String fTagParam = "";
    boolean headless = config.getBoolean(BSC.HEADLESS);
    if (filterTag != null) {
        fTagParam = "&" + BSC.FILTERTAG + "=" + URLEncoder.encode(filterTag, "UTF-8");
    }

    // Startup displays a big message and URL redirects after x seconds.
    // Snazzy.
    String initUrl = HOMEURL;
    // BUT...if a file is defined, (which it *should*),
    // then let's initialize with it instead.
    if (url != null && url.trim().length() > 0) {
        URLEncoder.encode(initUrl, "UTF-8");
        initUrl = HOMEURL + "?" + BSC.ACTION + "=" + BSC.INIT + "&" + BSC.TRANSIENT + "=" + transientState + "&"
                + BSC.URL + "=" + URLEncoder.encode(url, "UTF-8") + fTagParam;
    } else if (file != null && file.trim().length() > 0) {
        URLEncoder.encode(initUrl, "UTF-8");
        initUrl = HOMEURL + "?" + BSC.ACTION + "=" + BSC.INIT + "&" + BSC.TRANSIENT + "=" + transientState + "&"
                + BSC.FILE + "=" + URLEncoder.encode(file, "UTF-8") + fTagParam;
    } else {
        initUrl = HOMEURL + "?" + BSC.ACTION + "=" + BSC.INIT + "&" + BSC.TRANSIENT + "=" + transientState + "&"
                + BSC.FILE + "=" + URLEncoder.encode(MockeyXmlFileManager.MOCK_SERVICE_DEFINITION, "UTF-8")
                + fTagParam;

    }

    if (!(headless || isQuiteMode)) {
        new Thread(new BrowserThread("http://127.0.0.1", String.valueOf(port), initUrl, 0)).start();
        server.join();
    } else {
        initializeMockey(new URL("http://127.0.0.1" + ":" + String.valueOf(port) + initUrl));
    }
}

From source file:fr.inria.atlanmod.kyanos.benchmarks.KyanosGraphCreator.java

public static void main(String[] args) {
    Options options = new Options();

    Option inputOpt = OptionBuilder.create(IN);
    inputOpt.setArgName("INPUT");
    inputOpt.setDescription("Input file");
    inputOpt.setArgs(1);/*from   w  w  w. ja v a 2  s  .  c  o  m*/
    inputOpt.setRequired(true);

    Option outputOpt = OptionBuilder.create(OUT);
    outputOpt.setArgName("OUTPUT");
    outputOpt.setDescription("Output directory");
    outputOpt.setArgs(1);
    outputOpt.setRequired(true);

    Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS);
    inClassOpt.setArgName("CLASS");
    inClassOpt.setDescription("FQN of EPackage implementation class");
    inClassOpt.setArgs(1);
    inClassOpt.setRequired(true);

    Option optFileOpt = OptionBuilder.create(OPTIONS_FILE);
    optFileOpt.setArgName("FILE");
    optFileOpt.setDescription("Properties file holding the options to be used in the Kyanos Resource");
    optFileOpt.setArgs(1);

    options.addOption(inputOpt);
    options.addOption(outputOpt);
    options.addOption(inClassOpt);
    options.addOption(optFileOpt);

    CommandLineParser parser = new PosixParser();

    try {

        PersistenceBackendFactoryRegistry.getFactories().put(NeoBlueprintsURI.NEO_GRAPH_SCHEME,
                new BlueprintsPersistenceBackendFactory());

        CommandLine commandLine = parser.parse(options, args);

        URI sourceUri = URI.createFileURI(commandLine.getOptionValue(IN));
        URI targetUri = NeoBlueprintsURI.createNeoGraphURI(new File(commandLine.getOptionValue(OUT)));

        Class<?> inClazz = KyanosGraphCreator.class.getClassLoader()
                .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS));
        inClazz.getMethod("init").invoke(null);

        ResourceSet resourceSet = new ResourceSetImpl();

        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi",
                new XMIResourceFactoryImpl());
        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("zxmi",
                new XMIResourceFactoryImpl());
        resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap()
                .put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, PersistentResourceFactory.eINSTANCE);

        Resource sourceResource = resourceSet.createResource(sourceUri);
        Map<String, Object> loadOpts = new HashMap<String, Object>();
        if ("zxmi".equals(sourceUri.fileExtension())) {
            loadOpts.put(XMIResource.OPTION_ZIP, Boolean.TRUE);
        }

        Runtime.getRuntime().gc();
        long initialUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
        LOG.log(Level.INFO, MessageFormat.format("Used memory before loading: {0}",
                MessageUtil.byteCountToDisplaySize(initialUsedMemory)));
        LOG.log(Level.INFO, "Loading source resource");
        sourceResource.load(loadOpts);
        LOG.log(Level.INFO, "Source resource loaded");
        Runtime.getRuntime().gc();
        long finalUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
        LOG.log(Level.INFO, MessageFormat.format("Used memory after loading: {0}",
                MessageUtil.byteCountToDisplaySize(finalUsedMemory)));
        LOG.log(Level.INFO, MessageFormat.format("Memory use increase: {0}",
                MessageUtil.byteCountToDisplaySize(finalUsedMemory - initialUsedMemory)));

        Resource targetResource = resourceSet.createResource(targetUri);

        Map<String, Object> saveOpts = new HashMap<String, Object>();

        if (commandLine.hasOption(OPTIONS_FILE)) {
            Properties properties = new Properties();
            properties.load(new FileInputStream(new File(commandLine.getOptionValue(OPTIONS_FILE))));
            for (final Entry<Object, Object> entry : properties.entrySet()) {
                saveOpts.put((String) entry.getKey(), (String) entry.getValue());
            }
        }
        List<StoreOption> storeOptions = new ArrayList<StoreOption>();
        storeOptions.add(BlueprintsResourceOptions.EStoreGraphOption.AUTOCOMMIT);
        saveOpts.put(BlueprintsResourceOptions.STORE_OPTIONS, storeOptions);
        targetResource.save(saveOpts);

        LOG.log(Level.INFO, "Start moving elements");
        targetResource.getContents().clear();
        targetResource.getContents().addAll(sourceResource.getContents());
        LOG.log(Level.INFO, "End moving elements");
        LOG.log(Level.INFO, "Start saving");
        targetResource.save(saveOpts);
        LOG.log(Level.INFO, "Saved");

        if (targetResource instanceof PersistentResourceImpl) {
            PersistentResourceImpl.shutdownWithoutUnload((PersistentResourceImpl) targetResource);
        } else {
            targetResource.unload();
        }

    } catch (ParseException e) {
        MessageUtil.showError(e.toString());
        MessageUtil.showError("Current arguments: " + Arrays.toString(args));
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("java -jar <this-file.jar>", options, true);
    } catch (Throwable e) {
        MessageUtil.showError(e.toString());
    }
}

From source file:uk.ac.kcl.Main.java

public static void main(String[] args) {
    File folder = new File(args[0]);
    File[] listOfFiles = folder.listFiles();
    assert listOfFiles != null;
    for (File listOfFile : listOfFiles) {
        if (listOfFile.isFile()) {
            if (listOfFile.getName().endsWith(".properties")) {
                System.out.println("Properties sile found:" + listOfFile.getName()
                        + ". Attempting to launch application context");
                Properties properties = new Properties();
                InputStream input;
                try {
                    input = new FileInputStream(listOfFile);
                    properties.load(input);
                    if (properties.getProperty("globalSocketTimeout") != null) {
                        TcpHelper.setSocketTimeout(
                                Integer.valueOf(properties.getProperty("globalSocketTimeout")));
                    }/*from   www  .  ja  va 2  s . c  o m*/
                    Map<String, Object> map = new HashMap<>();
                    properties.forEach((k, v) -> {
                        map.put(k.toString(), v);
                    });
                    ConfigurableEnvironment environment = new StandardEnvironment();
                    MutablePropertySources propertySources = environment.getPropertySources();
                    propertySources.addFirst(new MapPropertySource(listOfFile.getName(), map));
                    @SuppressWarnings("resource")
                    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
                    ctx.registerShutdownHook();
                    ctx.setEnvironment(environment);
                    String scheduling;
                    try {
                        scheduling = properties.getProperty("scheduler.useScheduling");
                        if (scheduling.equalsIgnoreCase("true")) {
                            ctx.register(ScheduledJobLauncher.class);
                            ctx.refresh();
                        } else if (scheduling.equalsIgnoreCase("false")) {
                            ctx.register(SingleJobLauncher.class);
                            ctx.refresh();
                            SingleJobLauncher launcher = ctx.getBean(SingleJobLauncher.class);
                            launcher.launchJob();
                        } else if (scheduling.equalsIgnoreCase("slave")) {
                            ctx.register(JobConfiguration.class);
                            ctx.refresh();
                        } else {
                            throw new RuntimeException(
                                    "useScheduling not configured. Must be true, false or slave");
                        }
                    } catch (NullPointerException ex) {
                        throw new RuntimeException(
                                "useScheduling not configured. Must be true, false or slave");
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

From source file:com.welocalize.dispatcherMW.client.Main.java

public static void main(String[] args) throws InterruptedException, IOException {
    if (args.length >= 3) {
        String type = args[0];/*w  w w. j av  a2 s  . c o  m*/
        if (TYPE_TRANSLATE.equalsIgnoreCase(type)) {
            setbasicURl(args[1]);
            doJob(args[2], args[3]);
            return;
        } else if (TYPE_CHECK_STATUS.equalsIgnoreCase(type)) {
            setbasicURl(args[1]);
            checkJobStaus(args[2]);
            return;
        } else if (TYPE_DOWNLOAD.equalsIgnoreCase(type)) {
            setbasicURl(args[1]);
            downloadJob(args[2], args[3]);
            return;
        }
    } else if (args.length == 1) {
        Properties properties = new Properties();
        properties.load(new FileInputStream(args[0]));
        String type = properties.getProperty("type");
        setbasicURl(properties.getProperty("URL"));
        String securityCode = properties.getProperty(JSONPN_SECURITY_CODE);
        String filePath = properties.getProperty("filePath");
        String jobID = properties.getProperty(JSONPN_JOBID);
        if (TYPE_TRANSLATE.equalsIgnoreCase(type)) {
            doJob(securityCode, filePath);
            return;
        } else if (TYPE_CHECK_STATUS.equalsIgnoreCase(type)) {
            String status = checkJobStaus(jobID);
            System.out.println("The Status of Job:" + jobID + " is " + status + ". ");
            return;
        } else if (TYPE_DOWNLOAD.equalsIgnoreCase(type)) {
            downloadJob(jobID, securityCode);
            System.out.println("Download Job:" + jobID);
            return;
        }
    }

    // Print Help Message
    StringBuffer msg = new StringBuffer();
    msg.append("The Input is incorrect.").append("\n");
    msg.append("If you want to translate the XLF file, use this command:").append("\n");
    msg.append(" translate $URL $securityCode $filePath").append("\n");
    msg.append("If you only want to check job status, use this command:").append("\n");
    msg.append(" checkStatus $URL $jobID").append("\n");
    msg.append("If you only want to download the job file, use this command:").append("\n");
    msg.append(" download $URL $jobID $securityCode").append("\n");
    System.out.println(msg.toString());
}

From source file:com.ibm.watson.developer_cloud.professor_languo.pipeline.PipelineDriver.java

public static void main(String[] args) {
    Properties properties = new Properties();
    try (FileInputStream propertiesFileStream = new FileInputStream(args[0])) {
        // Load the properties from the properties file
        properties.load(propertiesFileStream);

        // Load the bluemix properties
        IndexerAndSearcherFactory.loadStaticBluemixProperties(properties);

        // Launch the pipeline
        drive(properties);//from w  w w  .  j  av a  2  s  .  c o m
    } catch (IOException | PipelineException e) {
        logger.fatal(e.getMessage());
        throw new RuntimeException(e);
    }
}