Example usage for java.lang Integer parseInt

List of usage examples for java.lang Integer parseInt

Introduction

In this page you can find the example usage for java.lang Integer parseInt.

Prototype

public static int parseInt(String s) throws NumberFormatException 

Source Link

Document

Parses the string argument as a signed decimal integer.

Usage

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

@SuppressWarnings("deprecation")
public static void main(String[] args) {
    try {//  ww w. j a  v a2 s.  c  o m
        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:com.jivesoftware.os.amza.service.AmzaSetStress.java

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

    args = new String[] { "soa-integ-data12.phx1.jivehosted.com", "1185", "1", "10000" };

    final String hostName = args[0];
    final int port = Integer.parseInt(args[1]);
    final int firstDocId = Integer.parseInt(args[2]);
    final int count = Integer.parseInt(args[3]);
    final int batchSize = 100;

    String partitionName = "lorem";

    for (int i = 0; i < 8; i++) {
        final String rname = partitionName + i;
        final org.apache.http.client.HttpClient httpClient = HttpClients.createDefault();

        Thread t = new Thread() {
            @Override/*from  w  ww  . j a  va 2s  .  c  om*/
            public void run() {
                try {
                    feed(httpClient, hostName, port, rname, 0, count, batchSize);
                } catch (Exception x) {
                    x.printStackTrace();
                }
            }
        };
        t.start();
    }
}

From source file:com.redhat.poc.jdg.bankofchina.util.GenerateUserIdCsv.java

public static void main(String[] args) throws Exception {
    CommandLine commandLine;/*from  w w w .j a v  a  2 s. c  o m*/
    Options options = new Options();
    options.addOption("s", true, "The start csv file number option");
    options.addOption("e", true, "The end csv file number option");
    BasicParser parser = new BasicParser();
    parser.parse(options, args);
    commandLine = parser.parse(options, args);
    if (commandLine.getOptions().length > 0) {
        if (commandLine.hasOption("s")) {
            String start = commandLine.getOptionValue("s");
            if (start != null && start.length() > 0) {
                csvFileStart = Integer.parseInt(start);
            }
        }
        if (commandLine.hasOption("e")) {
            String end = commandLine.getOptionValue("e");
            if (end != null && end.length() > 0) {
                csvFileEnd = Integer.parseInt(end);
            }
        }
    }

    for (int i = csvFileStart; i <= csvFileEnd; i++) {
        ReadCsvFile(i);
    }

    System.out.println();
    System.out.println("%%%%%%%%%  " + csvFileStart + "-" + csvFileEnd
            + " ? userid.csv ,? %%%%%%%%%");
    System.out.println("%%%%%%%%% userid.csv  " + userIdList.size() + " ? %%%%%%%%%");
    CSVWriter writer = new CSVWriter(new FileWriter(CSV_FILE_PATH + "userid.csv"));
    writer.writeAll(userIdList);
    writer.flush();
    writer.close();
}

From source file:edu.cuhk.hccl.cmd.AppQueryExpander.java

public static void main(String[] args) {

    try {//  w  w  w .  j av  a  2 s  . c o m

        CommandLineParser parser = new BasicParser();
        Options options = createOptions();
        CommandLine line = parser.parse(options, args);

        // Get parameters
        String queryStr = line.getOptionValue('q');
        int topK = Integer.parseInt(line.getOptionValue('k'));
        String modelPath = line.getOptionValue('m');
        String queryType = line.getOptionValue('t');

        QueryExpander expander = null;
        if (queryType.equalsIgnoreCase("WordVector")) {
            // Load word vectors
            System.out.println("[INFO] Loading word vectors...");
            expander = new WordVectorExpander(modelPath);
        } else if (queryType.equalsIgnoreCase("WordNet")) {
            // Load WordNet
            System.out.println("[INFO] Loading WordNet...");
            expander = new WordNetExpander(modelPath);
        } else {
            System.out.println("Please choose a correct expander: WordNet or WordVector!");
            System.exit(-1);
        }

        // Expand query
        System.out.println("[INFO] Computing similar words...");
        List<String> terms = expander.expandQuery(queryStr, topK);

        System.out.println(String.format("\n[INFO] The top %d similar words are: ", topK));
        for (String term : terms) {
            System.out.println(term);
        }

    } catch (ParseException exp) {
        System.out.println("Error in parameters: \n" + exp.getMessage());
        System.exit(-1);

    }
}

From source file:jetbrains.exodus.util.ForkedProcessRunner.java

@SuppressWarnings({ "HardcodedFileSeparator" })
public static void main(String[] args) throws Exception {
    log.info("Process started. Arguments: " + Arrays.toString(args));
    if (args.length < 2) {
        exit("Arguments do not contain port number and/or class to be run. Exit.", null);
    }/*from  ww  w.j  a  v a 2  s . c  o  m*/
    try {
        int port = Integer.parseInt(args[0]);
        socket = new Socket("localhost", port);
        streamer = new Streamer(socket);
    } catch (NumberFormatException e) {
        exit("Failed to parse port number: " + args[0] + ". Exit.", null);
    }
    ForkedLogic forkedLogic = null;
    try {
        Class<?> clazz = Class.forName(args[1]);
        forkedLogic = (ForkedLogic) clazz.getConstructor().newInstance();
    } catch (Exception e) {
        exit("Failed to instantiate or initialize ForkedLogic descendant", e);
    }
    // lets provide the peer with our process id
    streamer.writeString(getProcessId());
    String[] realArgs = new String[args.length - 2];
    System.arraycopy(args, 2, realArgs, 0, realArgs.length);
    forkedLogic.forked(realArgs);
}

From source file:StompMessageConsumer.java

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

    Options options = new Options();
    options.addOption("h", true, "Host to connect to");
    options.addOption("p", true, "Port to connect to");
    options.addOption("u", true, "User name");
    options.addOption("P", true, "Password");

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);

    String host = "192.168.1.7";
    String port = "61613";
    String user = "guest";
    String pass = "P@ssword1";

    if (cmd.hasOption("h")) {
        host = cmd.getOptionValue("h");
    }/*from   w  ww. j a  v  a 2s  . c om*/
    if (cmd.hasOption("p")) {
        port = cmd.getOptionValue("p");
    }
    if (cmd.hasOption("u")) {
        user = cmd.getOptionValue("u");
    }
    if (cmd.hasOption("P")) {
        pass = cmd.getOptionValue("P");
    }

    try {
        StompConnection connection = new StompConnection();

        connection.open(host, Integer.parseInt(port));
        connection.connect(user, pass);
        //      connection.open("orange.cloudtroopers.ro", 61613);
        //      connection.connect("system", "manager");

        connection.subscribe("jms.queue.memberRegistration", Subscribe.AckModeValues.CLIENT);
        connection.subscribe(StompMessagePublisher.MEMBER_REGISTRATION_JMS_DESTINATION,
                Subscribe.AckModeValues.CLIENT);

        connection.begin("tx2");
        StompFrame message = connection.receive();
        System.out.println(message.getBody());
        connection.ack(message, "tx2");
        connection.commit("tx2");

        connection.disconnect();
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.tdmx.server.runtime.ServerLauncher.java

public static void main(String[] args) {
    String javaVersion = System.getProperty("java.version");

    StringTokenizer tokens = new StringTokenizer(javaVersion, ".-_");

    int majorVersion = Integer.parseInt(tokens.nextToken());
    int minorVersion = Integer.parseInt(tokens.nextToken());

    if (majorVersion < 2 && minorVersion < 7) {
        log.error("TDMX-Server requires Java 7 or later.");
        log.error("Your java version is " + javaVersion);
        log.error("Java Home:  " + System.getProperty("java.home"));
        System.exit(-1);//from w  w w .jav a  2 s .c o m
    }

    // Construct the SpringApplication
    BeanFactoryLocator beanFactoryLocator = ContextSingletonBeanFactoryLocator.getInstance();
    BeanFactoryReference beanFactoryReference = beanFactoryLocator.useBeanFactory("applicationContext");
    ApplicationContext context = (ApplicationContext) beanFactoryReference.getFactory();

    SslServerSocketInfo si = (SslServerSocketInfo) context.getBean("server.sslInfo");
    log.info("JVM supportedCipherSuites: "
            + StringUtils.arrayToCommaDelimitedString(si.getSupportedCipherSuites()));
    log.info("JVM supportedProtocols: " + StringUtils.arrayToCommaDelimitedString(si.getSupportedProtocols()));
    log.info("default TrustManagerFactoryAlgorithm: " + si.getDefaultTrustManagerFactoryAlgorithm());

    // Start the Jetty
    ServerContainer sc = (ServerContainer) context.getBean("server.Container");
    sc.runUntilStopped();
}

From source file:birch.util.EncryptionKeyFileUtil.java

public static void main(String[] args) {
    try {//from w  w w  . j  ava2s.  c om

        String cipher = "AES";
        int keysize = 128;

        if (args.length > 0) {
            cipher = args[0];
        }
        if (args.length > 1) {
            keysize = Integer.parseInt(args[1]);
        }

        System.out.println("Cipher algorithm " + cipher + " used to create a " + keysize + "bit key:");
        System.out.println(createKey(cipher, keysize));

    } catch (Throwable ex) {
        Logger.getLogger(EncryptionKeyFileUtil.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:edu.scripps.fl.test.pubchem.test.FetchFromDepositionSystemTest.java

public static void main(String[] args) throws Exception {
    //      BasicConfigurator.configure();
    //      org.apache.log4j.Logger.getRootLogger().setLevel(Level.INFO);
    DOMConfigurator.configure(FetchFromDepositionSystemTest.class.getResource("/log4j.config.xml"));

    PCDepositionSystemSession session = new PCDepositionSystemSession();
    session.DEBUGGING = true;//from w w w.  j  a  va 2 s  .  c om
    session.login(args[0], args[1]);
    for (int ii = 2; ii < args.length; ii++) {
        int aid = Integer.parseInt(args[ii]);
        log.info("Fetching outcome counts.");
        PCOutcomeCounts counts = session.getSubstanceOutcomeCounts(aid);
        log.info(String.format(
                "Substance counts for AID %s: All: %s, Probe: %s, Active: %s, Inactive: %s, Inconclusive: %s",
                aid, counts.all, counts.probe, counts.active, counts.inactive, counts.inconclusive));

        log.info("Fetching full XML.");
        displayFile(aid, session.getAssayXML(aid), "xml");

        log.info("Fetching description XML.");
        displayFile(aid, session.getDescrXML(aid), "xml");

        log.info("Fetching CSV.");
        displayFile(aid, session.getAssayCSV(aid), "csv");

        log.info("Fetching SDF.");
        displayFile(aid, session.getAssaySDF(aid), "sdf");

        log.info("SIDS for AID " + aid + ": " + session.getAssaySIDs(aid));
    }
}

From source file:com.barchart.udt.AppServer.java

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

    int port = 9000;

    if (args.length > 1) {
        System.out.println("usage: appserver [server_port]");
        return;/* w w  w.j  a  v  a  2s  .  c  o  m*/
    }

    if (args.length == 1) {
        port = Integer.parseInt(args[0]);
    }

    final NetServerSocketUDT acceptorSocket = new NetServerSocketUDT();
    acceptorSocket.bind(new InetSocketAddress(getLocalHost(), port), 256);

    System.out.printf("server is ready at port: %d\n", port);
    System.out.println("server is ready");
    while (true) {

        final Socket clientSocket = acceptorSocket.accept();

        // Start the read ahead background task
        Executors.newSingleThreadExecutor().submit(new Callable<Boolean>() {
            @Override
            public Boolean call() {
                return clientTask(clientSocket);
            }
        });
    }
}