Example usage for java.lang System getProperty

List of usage examples for java.lang System getProperty

Introduction

In this page you can find the example usage for java.lang System getProperty.

Prototype

public static String getProperty(String key) 

Source Link

Document

Gets the system property indicated by the specified key.

Usage

From source file:net.itransformers.bgpPeeringMap.BgpPeeringMapFromFile.java

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

    Map<String, String> params = CmdLineParser.parseCmdLine(args);
    logger.info("input params" + params.toString());
    final String settingsFile = params.get("-s");
    if (settingsFile == null) {
        printUsage("bgpPeeringMap.properties");
        return;//from   w w  w  .j a v a 2s.c om
    }

    Map<String, String> settings = loadProperties(new File(System.getProperty("base.dir"), settingsFile));
    logger.info("Settings" + settings.toString());

    File outputDir = new File(System.getProperty("base.dir"), settings.get("output.dir"));
    System.out.println(outputDir.getAbsolutePath());
    boolean result = outputDir.mkdir();
    //        if (!result) {
    //            System.out.println("result:"+result);
    //            System.out.println("Unable to create dir: "+outputDir);
    //            return;
    //        }

    File graphmlDir = new File(outputDir, settings.get("output.dir.graphml"));
    result = outputDir.mkdir();
    //        if (!result) {
    //            System.out.println("Unable to create dir: "+graphmlDir);
    //            return;
    //        }

    XsltTransformer transformer = new XsltTransformer();
    byte[] rawData = readRawDataFile(settings.get("raw-data-file"));
    logger.info("First-transformation has started with xsltTransformator " + settings.get("xsltFileName1"));

    ByteArrayOutputStream outputStream1 = new ByteArrayOutputStream();
    File xsltFileName1 = new File(System.getProperty("base.dir"), settings.get("xsltFileName1"));
    ByteArrayInputStream inputStream1 = new ByteArrayInputStream(rawData);
    // transformer.transformXML(inputStream1, xsltFileName1, outputStream1, settings);
    logger.info("First transformation finished");
    File outputFile1 = new File(graphmlDir, "bgpPeeringMap-intermediate.xml");

    FileUtils.writeStringToFile(outputFile1, new String(outputStream1.toByteArray()));

    logger.info("Second transformation started with xsltTransformator " + settings.get("xsltFileName2"));

    ByteArrayOutputStream outputStream2 = new ByteArrayOutputStream();
    File xsltFileName2 = new File(System.getProperty("base.dir"), settings.get("xsltFileName2"));
    ByteArrayInputStream inputStream2 = new ByteArrayInputStream(outputStream1.toByteArray());
    // transformer.transformXML(inputStream2, xsltFileName2, outputStream2, settings);
    logger.info("Second transformation finished");
    File outputFile = new File(graphmlDir, "bgpPeeringMap.graphml");
    File nodesFileListFile = new File(graphmlDir, "nodes-file-list.txt");
    FileUtils.writeStringToFile(outputFile, new String(outputStream2.toByteArray()));
    logger.info("Output Graphml saved in a file in" + graphmlDir);

    FileUtils.writeStringToFile(nodesFileListFile, "bgpPeeringMap.graphml");

    ByteArrayInputStream inputStream3 = new ByteArrayInputStream(outputStream2.toByteArray());
    ByteArrayOutputStream outputStream3 = new ByteArrayOutputStream();
    File xsltFileName3 = new File(System.getProperty("base.dir"), settings.get("xsltFileName3"));
    // transformer.transformXML(inputStream3, xsltFileName3, outputStream3);

}

From source file:com.ebay.myriad.Main.java

public static void main(String[] args) throws Exception {
    new Main().run(new String[] { "server", System.getProperty(Constants.CONFIG_PROPERTY) });
}

From source file:SendMail.java

public static void main(String[] args) {
    try {/*from www . j a  v a  2  s.c o m*/
        // If the user specified a mailhost, tell the system about it.
        if (args.length >= 1)
            System.getProperties().put("mail.host", args[0]);

        // A Reader stream to read from the console
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        // Ask the user for the from, to, and subject lines
        System.out.print("From: ");
        String from = in.readLine();
        System.out.print("To: ");
        String to = in.readLine();
        System.out.print("Subject: ");
        String subject = in.readLine();

        // Establish a network connection for sending mail
        URL u = new URL("mailto:" + to); // Create a mailto: URL
        URLConnection c = u.openConnection(); // Create its URLConnection
        c.setDoInput(false); // Specify no input from it
        c.setDoOutput(true); // Specify we'll do output
        System.out.println("Connecting..."); // Tell the user
        System.out.flush(); // Tell them right now
        c.connect(); // Connect to mail host
        PrintWriter out = // Get output stream to host
                new PrintWriter(new OutputStreamWriter(c.getOutputStream()));

        // We're talking to the SMTP server now.
        // Write out mail headers. Don't let users fake the From address
        out.print("From: \"" + from + "\" <" + System.getProperty("user.name") + "@"
                + InetAddress.getLocalHost().getHostName() + ">\r\n");
        out.print("To: " + to + "\r\n");
        out.print("Subject: " + subject + "\r\n");
        out.print("\r\n"); // blank line to end the list of headers

        // Now ask the user to enter the body of the message
        System.out.println("Enter the message. " + "End with a '.' on a line by itself.");
        // Read message line by line and send it out.
        String line;
        for (;;) {
            line = in.readLine();
            if ((line == null) || line.equals("."))
                break;
            out.print(line + "\r\n");
        }

        // Close (and flush) the stream to terminate the message
        out.close();
        // Tell the user it was successfully sent.
        System.out.println("Message sent.");
    } catch (Exception e) { // Handle any exceptions, print error message.
        System.err.println(e);
        System.err.println("Usage: java SendMail [<mailhost>]");
    }
}

From source file:com.gagein.crawler.Extractor.java

public static void main(String[] args) {
    String website = "http://www.gagein.com";
    String tempName = "temp";
    // ???/* ww  w  .j a  v  a  2 s .  c o  m*/
    String dirPath = System.getProperty("user.dir") + File.separator + tempName + File.separator
            + website.substring(7).split("\\.")[1];// remove http://;
    Extractor ex = new Extractor();
    ex.getFilesPath(dirPath);
    System.out.println(ex.pathSet);
    ArticleStripper as = new ArticleStripper();
    as.setExtractAuthor(false);
    as.setExtractContent(true);
    as.setExtractDate(false);
    as.setExtractImg(false);
    as.setKeepContentLink(false);
    for (String url : ex.pathSet) {
        System.out.println(url);
        File file = new File(url);
        try {
            String page = FileUtils.readFileToString(file);
            System.out.println("Contents of file: " + page);
            logger.debug("==============?" + url + "?");
            Article article = as.retrieveArticle(null, null, page, null);
            System.out.println("##################" + article.getContent());

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

From source file:com.ikanow.aleph2.remote.es_tests.SimpleReadableCrudTest.java

public static void main(final String args[]) throws Exception {
    if (args.length < 1) {
        System.out.println("CLI: <host>");
        System.exit(-1);//from   w w w. ja  va  2 s  .  c om
    }

    final String temp_dir = System.getProperty("java.io.tmpdir") + File.separator;

    Config config = ConfigFactory
            .parseReader(new InputStreamReader(
                    SimpleReadableCrudTest.class.getResourceAsStream("/test_es_remote.properties")))
            .withValue("globals.local_root_dir", ConfigValueFactory.fromAnyRef(temp_dir))
            .withValue("globals.local_cached_jar_dir", ConfigValueFactory.fromAnyRef(temp_dir))
            .withValue("globals.distributed_root_dir", ConfigValueFactory.fromAnyRef(temp_dir))
            .withValue("globals.local_yarn_config_dir", ConfigValueFactory.fromAnyRef(temp_dir))
            .withValue("MongoDbManagementDbService.mongodb_connection",
                    ConfigValueFactory.fromAnyRef(args[0] + ":27017"))
            .withValue("ElasticsearchCrudService.elasticsearch_connection",
                    ConfigValueFactory.fromAnyRef(args[0] + ":9300"));

    final SimpleReadableCrudTest app = new SimpleReadableCrudTest();

    final Injector app_injector = ModuleUtils.createTestInjector(Arrays.asList(), Optional.of(config));
    app_injector.injectMembers(app);

    app.runTest();
    System.exit(0);
}

From source file:Main.java

public static void main(String[] args) {

    File workingDirectory = new File("C:" + File.separator + "Invoices");

    File template = new File(workingDirectory.getAbsolutePath() + File.separator + "invoiceTemplate.tex");

    File tempDir = new File(workingDirectory.getAbsolutePath() + File.separator + "temp");
    if (!tempDir.isDirectory()) {
        tempDir.mkdir();//  w  w w  .j a  v a2 s.c om
    }

    File invoice1 = new File(tempDir.getAbsolutePath() + File.separator + "invoice1.tex");
    File invoice2 = new File(tempDir.getAbsolutePath() + File.separator + "invoice2.tex");

    try {

        HashMap<String, String> data = new HashMap<String, String>();

        data.put("Number", "1");
        data.put("Customer name", "Ivan Pfeiffer");
        data.put("Customer street", "Schwarzer Weg 4");
        data.put("Customer zip", "13505 Berlin");
        data.put("Development", "Software");
        data.put("Price", "500");

        JLRConverter converter = new JLRConverter("::", ":::");
        if (!converter.parse(template, invoice1, data)) {
            System.out.println(converter.getErrorMessage());
        }

        data.put("Number", "2");
        data.put("Customer name", "Mike Mueller");
        data.put("Customer street", "Prenzlauer Berg 12");
        data.put("Customer zip", "10405 Berlin");
        data.put("Development", "Hardware");
        data.put("Price", "2350");

        if (!converter.parse(template, invoice2, data)) {
            System.out.println(converter.getErrorMessage());
        }

        File desktop = new File(System.getProperty("user.home") + File.separator + "Desktop");

        JLRGenerator pdfGen = new JLRGenerator();

        pdfGen.deleteTempTexFile(false);

        if (!pdfGen.generate(invoice1, desktop, workingDirectory)) {
            System.out.println(pdfGen.getErrorMessage());
        }

        JLROpener.open(pdfGen.getPDF());

        if (!pdfGen.generate(invoice2, desktop, workingDirectory)) {
            System.out.println(pdfGen.getErrorMessage());
        }

        JLROpener.open(pdfGen.getPDF());

    } catch (IOException ex) {
        System.err.println(ex.getMessage());
    }
}

From source file:com.redhat.red.koji.build.Main.java

public static void main(String[] args) {
    String noExit = System.getProperty(NO_EXIT);
    boolean exit = noExit == null || !Boolean.parseBoolean(noExit);
    Integer result = null;/*from   ww w  .ja  va2s . c  o  m*/

    Options opts = new Options();
    try {
        if (!opts.parseArgs(args)) {
            result = 0;
        }
    } catch (CmdLineException e) {
        e.printStackTrace();
        result = PARSE_ERROR;
    }

    if (result == null) {
        result = new Main(opts).run();
    }

    if (exit) {
        System.exit(result);
    }
}

From source file:com.cisco.dbds.utils.report.CustomReport.java

/**
 * The main method.// w  w w .ja v a 2  s . c  om
 *
 * @param args the arguments
 * @throws FileNotFoundException the file not found exception
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws ParseException the parse exception
 * @throws AddressException the address exception
 */
public static void main(String[] args)
        throws FileNotFoundException, IOException, ParseException, AddressException {

    // reportparsejson();
    String msg = reportparsejson();
    sendmail(msg);
    String eol = System.getProperty("line.separator");
    //msg=msg.replaceAll("</tr>", eol+"</tr>");
    msg = msg.replaceAll("<tr", eol + "<tr");
    msg = msg.replaceAll("</table>", eol + "</table>");
    msg = msg.replaceAll("<table", eol + "<table");
    new FileOutputStream(htmlfname).close();
    htmlfile = new PrintWriter(new BufferedWriter(new FileWriter(htmlfname, true)));

    htmlfile.print(msg);
    htmlfile.close();

    // String mailContent = "Hi All<br>"+
    // "Build Tag id: jenkins-CANEAS-Nightly-Completed-190 has been completed and the run reports  found in the link: http://10.78.216.52:8080/job/CANEAS-Nightly-Completed/190/cucumber-html-reports/"
    // + "<br>"
    // +
    //
    // "EDCS link for failure analysis Reasons: http://wwwin-eng.cisco.com/cgi-bin/edcs/edcs_info?3677074"
    // + "<br>"
    // +
    // "(will be updated soon for the Build: jenkins-CANEAS-Nightly-Completed-190 )"
    // + "<br><br>" + "Regards" + "<br>" + "SIT Automation TEAM"
    // + "<br>";
    // sendmail(mailContent);
}

From source file:de.unisb.cs.st.javalanche.rhino.RhinoTestDriver.java

public static void main(String[] args)
        throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    if (System.getProperty(SINGLE_TEST_NAME_KEY) != null) {
        new RhinoTestDriver().runSingleTest();
    } else {//from www  .  j  a v a 2s. c o m
        if (dirMode) {
            String dirName = System.getProperty("rhino.dir");

            if (dirName != null) {
                File directory = new File(dirName);
                new RhinoTestDriver().testDirectory(directory);
            }
        } else if (makeFileMode) {
            String dirName = System.getProperty("rhino.dir");

            if (dirName != null) {
                File directory = new File(dirName);
                new RhinoTestDriver().generateMakefile(directory);
            }

        } else {
            new RhinoTestDriver().run();
        }
    }
}

From source file:net.dv8tion.discord.Yui.java

public static void main(String[] args) throws InterruptedException, UnsupportedEncodingException {
    if (System.getProperty("file.encoding").equals("UTF-8")) {
        setupBot();//from   w  w w.j  a  v a  2  s .  c  o m
    } else {
        relaunchInUTF8();
    }
}