Example usage for java.lang Integer toString

List of usage examples for java.lang Integer toString

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static String toString(int i) 

Source Link

Document

Returns a String object representing the specified integer.

Usage

From source file:Main.java

public static List<String> GetMonthList() {
    List<String> monthList = new ArrayList<String>();

    for (int i = 0; i < 12; i++) {
        monthList.add(Integer.toString(i + 1));
    }/*from   w  w w.j  a  va  2  s .  c  o  m*/

    return monthList;
}

From source file:Main.java

private static double getdPoint(double num) {
    double d = num;
    int fInt = (int) d;
    BigDecimal b1 = new BigDecimal(Double.toString(d));
    BigDecimal b2 = new BigDecimal(Integer.toString(fInt));
    double dPoint = b1.subtract(b2).floatValue();
    return dPoint;
}

From source file:Main.java

public static double getdPoint(double num) {
    double d = num;
    int fInt = (int) d;
    BigDecimal b1 = new BigDecimal(Double.toString(d));
    BigDecimal b2 = new BigDecimal(Integer.toString(fInt));
    double dPoint = b1.subtract(b2).floatValue();
    return dPoint;

}

From source file:Main.java

public static HashMap<String, String> getEANHashMap(String[] eans) {
    HashMap<String, String> ret = new HashMap<String, String>();
    for (int i = 0; i < eans.length; i++) {
        ret.put(eans[i], Integer.toString(i + 1));
    }/*w w w.  j  av  a  2 s. c  om*/
    return ret;
}

From source file:Main.java

public static String bytesToString(byte[] value) {
    String result = "";
    if (value == null)
        return "<empty>";

    for (byte b : value) {
        if (result.length() == 0)
            result += Integer.toString(b);
        else//w  w  w  .ja  va  2  s.  c  o m
            result += ":" + Integer.toString(b);
    }
    return result;
}

From source file:com.esri.geoevent.test.tools.RunTcpInTcpOutTest.java

public static void main(String args[]) {
    int numberEvents = 10000;
    //int brake = 1000;
    String server = "ags104";
    int in_port = 5565;
    int out_port = 5575;
    int start_rate = 5000;
    int end_rate = 5005;
    int rate_step = 1;

    Options opts = new Options();
    opts.addOption("n", true, "Number of Events");
    opts.addOption("s", true, "Server");
    opts.addOption("i", true, "Input TCP Port");
    opts.addOption("o", true, "Output TCP Port");
    opts.addOption("r", true, "Range");
    opts.addOption("h", false, "Help");
    try {/*from   ww w  .j  a  v a2 s.c  o  m*/

        CommandLineParser parser = new BasicParser();
        CommandLine cmd = null;

        try {
            cmd = parser.parse(opts, args, false);
        } catch (ParseException ignore) {
            System.err.println(ignore.getMessage());
        }

        String cmdInputErrorMsg = "";

        if (cmd.getOptions().length == 0 || cmd.hasOption("h")) {
            throw new ParseException("Show Help");
        }

        if (cmd.hasOption("n")) {
            String val = cmd.getOptionValue("n");
            try {
                numberEvents = Integer.valueOf(val);
            } catch (NumberFormatException e) {
                cmdInputErrorMsg += "Invalid value for n. Must be integer.\n";
            }
        }

        if (cmd.hasOption("s")) {
            server = cmd.getOptionValue("s");
        }

        if (cmd.hasOption("i")) {
            String val = cmd.getOptionValue("i");
            try {
                in_port = Integer.valueOf(val);
            } catch (NumberFormatException e) {
                cmdInputErrorMsg += "Invalid value for i. Must be integer.\n";
            }
        }

        if (cmd.hasOption("o")) {
            String val = cmd.getOptionValue("o");
            try {
                out_port = Integer.valueOf(val);
            } catch (NumberFormatException e) {
                cmdInputErrorMsg += "Invalid value for o. Must be integer.\n";
            }
        }

        if (cmd.hasOption("r")) {
            String val = cmd.getOptionValue("r");
            try {
                String parts[] = val.split(",");
                if (parts.length == 3) {
                    start_rate = Integer.parseInt(parts[0]);
                    end_rate = Integer.parseInt(parts[1]);
                    rate_step = Integer.parseInt(parts[2]);
                } else if (parts.length == 1) {
                    // Run single rate
                    start_rate = Integer.parseInt(parts[0]);
                    end_rate = start_rate;
                    rate_step = start_rate;
                } else {
                    throw new ParseException("Rate must be three comma seperated values or a single value");
                }

            } catch (ParseException e) {
                cmdInputErrorMsg += e.getMessage();
            } catch (NumberFormatException e) {
                cmdInputErrorMsg += "Invalid value for r. Must be integers.\n";
            }
        }

        if (!cmdInputErrorMsg.equalsIgnoreCase("")) {
            throw new ParseException(cmdInputErrorMsg);
        }
        DecimalFormat df = new DecimalFormat("##0");
        RunTcpInTcpOutTest t = new RunTcpInTcpOutTest();

        if (start_rate == end_rate) {
            // Single Rate Test
            System.out.println("*********************************");
            System.out.println("Incremental testing at requested rate: " + start_rate);
            System.out.println("Count,Incremental Rate");

            t.runTest(numberEvents, start_rate, server, in_port, out_port, true);
            if (t.send_rate < 0 || t.rcv_rate < 0) {
                throw new Exception("Test Run Failed!");
            }
            System.out.println("Overall Average Send Rate, Received Rate");
            System.out.println(df.format(t.send_rate) + "," + df.format(t.rcv_rate));

        } else {
            System.out.println("*********************************");
            System.out.println("rateRqstd,avgSendRate,avgRcvdRate");

            //for (int rate: rates) {
            for (int rate = start_rate; rate <= end_rate; rate += rate_step) {

                t.runTest(numberEvents, rate, server, in_port, out_port, false);
                if (t.send_rate < 0 || t.rcv_rate < 0) {
                    throw new Exception("Test Run Failed!");
                }
                System.out.println(
                        Integer.toString(rate) + "," + df.format(t.send_rate) + "," + df.format(t.rcv_rate));
            }

        }

    } catch (ParseException e) {
        System.out.println("Invalid Command Options: ");
        System.out.println(e.getMessage());
        System.out.println(
                "Command line options: -n NumEvents -s Server -i InputPort -o OutputPort -r StartRate,EndRate,Step");

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

}

From source file:Main.java

public static String getCurrentHour() {
    Calendar calendar = Calendar.getInstance();
    int nHour = calendar.get(Calendar.HOUR_OF_DAY);
    if (nHour < 10)
        return "0" + Integer.toString(nHour);
    else/*from ww w.ja v a  2 s . com*/
        return Integer.toString(nHour);
}

From source file:Main.java

public static String getCurrentMonth() {
    Calendar calendar = Calendar.getInstance();
    int nMonth = calendar.get(Calendar.MONTH) + 1;
    if (nMonth < 10)
        return "0" + Integer.toString(nMonth);
    else//from  www  . j a  va2  s  .  c o  m
        return Integer.toString(nMonth);
}

From source file:Main.java

public static String[] intToString(ArrayList<Integer> list) {
    String string[] = new String[list.size()];
    for (int i = 0; i < string.length; i++) {
        string[i] = Integer.toString(list.get(i));
    }/*from  ww  w  .j  ava2 s. c  o m*/
    return string;
}

From source file:Main.java

public static Element toXML(Point p, Document document) {
    Element result = document.createElement("center");
    result.setAttribute("x", Integer.toString(p.x));
    result.setAttribute("y", Integer.toString(p.y));
    return result;
}