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 void main(String... args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel contentPane = new JPanel();
    contentPane.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
    JTextField tfield1 = new JTextField(10);
    JTextField tfield2 = new JTextField(10);

    FocusListener tfieldListener = new FocusListener() {
        @Override//from   w w w.  j a v a 2  s . com
        public void focusGained(FocusEvent fe) {
        }

        @Override
        public void focusLost(FocusEvent fe) {
            String num1 = tfield1.getText().trim();
            String num2 = tfield2.getText().trim();
            if (num1 == null || num1.equals(""))
                num1 = "0";
            if (num2 == null || num2.equals(""))
                num2 = "0";
            System.out.println(Integer.toString(Integer.parseInt(num1) + Integer.parseInt(num2)));
        }
    };

    tfield1.addFocusListener(tfieldListener);
    tfield2.addFocusListener(tfieldListener);

    ((AbstractDocument) tfield1.getDocument()).setDocumentFilter(new MyDocumentFilter());
    ((AbstractDocument) tfield2.getDocument()).setDocumentFilter(new MyDocumentFilter());

    contentPane.add(tfield1);
    contentPane.add(tfield2);

    frame.setContentPane(contentPane);
    frame.pack();
    frame.setLocationByPlatform(true);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document document = documentBuilder.parse("server.xml");
    Element root = document.getDocumentElement();
    Element rootElement = document.getDocumentElement();

    Collection<Server> svr = new ArrayList<Server>();
    svr.add(new Server());

    for (Server i : svr) {
        Element server = document.createElement("server");
        rootElement.appendChild(server);

        Element name = document.createElement("name");
        name.appendChild(document.createTextNode(i.getName()));
        server.appendChild(name);//from   w w  w .j  a  va2 s . co m

        Element port = document.createElement("port");
        port.appendChild(document.createTextNode(Integer.toString(i.getPort())));
        server.appendChild(port);

        root.appendChild(server);
    }

    DOMSource source = new DOMSource(document);

    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    StreamResult result = new StreamResult("server.xml");
    transformer.transform(source, result);
}

From source file:org.bigtextml.drivers.BigMapReadTest.java

public static void main(String[] args) {
    /*/*from  w  w w  . j av a  2  s  . c o  m*/
    ApplicationContext context = 
    new ClassPathXmlApplicationContext(new String[] {"InMemoryDataMining.xml"});
    */
    System.out.println(System.getProperty("InvokedFromSpring"));
    //Map<String,List<Integer>> bm = context.getBean("bigMapTest",BigMap.class);
    Map<String, List<Integer>> bm = ManagementServices.getBigMap("tmCache");
    System.out.println(((BigMap) bm).getCacheName());
    int max = 1000000;

    String key = Integer.toString(max - 1);
    //bm.remove(key);
    for (int i = 0; i < 3; i++) {
        long millis = System.currentTimeMillis();
        System.out.println(bm.get(Integer.toString(500000)));
        System.out.println(System.currentTimeMillis() - millis);
    }
    bm.clear();
}

From source file:org.bigtextml.drivers.BigMapTest.java

public static void main(String[] args) {
    /*//from   ww w. j a v  a  2 s .co  m
    ApplicationContext context = 
    new ClassPathXmlApplicationContext(new String[] {"InMemoryDataMining.xml"});
    */
    System.out.println(System.getProperty("InvokedFromSpring"));
    //Map<String,List<Integer>> bm = context.getBean("bigMapTest",BigMap.class);
    Map<String, List<Integer>> bm = ManagementServices.getBigMap("tmCache");
    System.out.println(((BigMap) bm).getCacheName());
    int max = 1000000;

    //bm.setMaxCapacity(1000);

    for (int i = 0; i < max; i++) {
        List<Integer> x = new ArrayList<Integer>();
        for (int j = 0; j < 5; j++) {
            x.add(j);
        }
        x.add(i);
        bm.put(Integer.toString(i), x);
    }
    String key = Integer.toString(max - 1);
    //bm.remove(key);
    for (int i = 0; i < 3; i++) {
        long millis = System.currentTimeMillis();
        System.out.println(bm.get(Integer.toString(500000)));
        System.out.println(System.currentTimeMillis() - millis);
    }
    bm.clear();
}

From source file:com.netcore.hsmart.dataconsumers.SmsDataConsumer.java

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

    ExecutorService executor = Executors.newCachedThreadPool();

    for (int i = 1; i <= COUNTERS; i++) {
        Runnable worker = new SmsDataConsumerRunnable(Integer.toString(i), Integer.toString(GID));
        executor.execute(worker);/* ww  w . j  a va  2 s.  c  o  m*/
    }
}

From source file:com.netcore.hsmart.dataconsumers.DlrDataConsumer.java

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

    ExecutorService executor = Executors.newCachedThreadPool();

    for (int i = 1; i <= COUNTERS; i++) {
        Runnable worker = new DlrDataConsumerRunnable(Integer.toString(i), Integer.toString(GID));
        executor.execute(worker);//w  w  w .j av  a2  s.co  m
    }
}

From source file:ScrollPaneWatermark.java

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

    JTextArea ta = new JTextArea();
    for (int i = 0; i < 1000; i++) {
        ta.append(Integer.toString(i) + "  ");
    }// ww  w.j a v  a 2s .com

    ta.setLineWrap(true);
    ta.setWrapStyleWord(true);
    // ta.setOpaque(false);

    ScrollPaneWatermark watermark = new ScrollPaneWatermark();
    watermark.setBackgroundTexture(new File("background.jpg").toURL());
    watermark.setForegroundBadge(new File("foreground.png").toURL());
    watermark.setView(ta);

    JScrollPane scroll = new JScrollPane();
    scroll.setViewport(watermark);

    frame.getContentPane().add(scroll);
    frame.pack();
    frame.setSize(600, 600);
    frame.setVisible(true);
}

From source file:io.druid.query.aggregation.datasketches.quantiles.GenerateTestData.java

public static void main(String[] args) throws Exception {
    Path buildPath = FileSystems.getDefault().getPath("doubles_build_data.tsv");
    Path sketchPath = FileSystems.getDefault().getPath("doubles_sketch_data.tsv");
    BufferedWriter buildData = Files.newBufferedWriter(buildPath, StandardCharsets.UTF_8);
    BufferedWriter sketchData = Files.newBufferedWriter(sketchPath, StandardCharsets.UTF_8);
    Random rand = new Random();
    int sequenceNumber = 0;
    for (int i = 0; i < 20; i++) {
        int product = rand.nextInt(10);
        UpdateDoublesSketch sketch = UpdateDoublesSketch.builder().build();
        for (int j = 0; j < 20; j++) {
            double value = rand.nextDouble();
            buildData.write("2016010101");
            buildData.write('\t');
            buildData.write(Integer.toString(sequenceNumber)); // dimension with unique numbers for ingesting raw data
            buildData.write('\t');
            buildData.write(Integer.toString(product)); // product dimension
            buildData.write('\t');
            buildData.write(Double.toString(value));
            buildData.newLine();//from  w  w w.  j a va2  s  .  co m
            sketch.update(value);
            sequenceNumber++;
        }
        sketchData.write("2016010101");
        sketchData.write('\t');
        sketchData.write(Integer.toString(product)); // product dimension
        sketchData.write('\t');
        sketchData.write(Base64.encodeBase64String(sketch.toByteArray(true)));
        sketchData.newLine();
    }
    buildData.close();
    sketchData.close();
}

From source file:org.eclipse.swt.snippets.Snippet192.java

public static void main(String[] args) {
    // initialize data with keys and random values
    int size = 100;
    Random random = new Random();
    final int[][] data = new int[size][];
    for (int i = 0; i < data.length; i++) {
        data[i] = new int[] { i, random.nextInt() };
    }/*from w  ww  . java2s.  c o m*/
    // create a virtual table to display data
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 192");
    shell.setLayout(new FillLayout());
    final Table table = new Table(shell, SWT.VIRTUAL);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setItemCount(size);
    final TableColumn column1 = new TableColumn(table, SWT.NONE);
    column1.setText("Key");
    column1.setWidth(200);
    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setText("Value");
    column2.setWidth(200);
    table.addListener(SWT.SetData, e -> {
        TableItem item = (TableItem) e.item;
        int index = table.indexOf(item);
        int[] datum = data[index];
        item.setText(new String[] { Integer.toString(datum[0]), Integer.toString(datum[1]) });
    });
    // Add sort indicator and sort data when column selected
    Listener sortListener = e -> {
        // determine new sort column and direction
        TableColumn sortColumn = table.getSortColumn();
        TableColumn currentColumn = (TableColumn) e.widget;
        int dir = table.getSortDirection();
        if (sortColumn == currentColumn) {
            dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
        } else {
            table.setSortColumn(currentColumn);
            dir = SWT.UP;
        }
        // sort the data based on column and direction
        final int index = currentColumn == column1 ? 0 : 1;
        final int direction = dir;
        Arrays.sort(data, (a, b) -> {
            if (a[index] == b[index])
                return 0;
            if (direction == SWT.UP) {
                return a[index] < b[index] ? -1 : 1;
            }
            return a[index] < b[index] ? 1 : -1;
        });
        // update data displayed in table
        table.setSortDirection(dir);
        table.clearAll();
    };
    column1.addListener(SWT.Selection, sortListener);
    column2.addListener(SWT.Selection, sortListener);
    table.setSortColumn(column1);
    table.setSortDirection(SWT.UP);
    shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, 300);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:fr.inria.zenith.randomWalk.RandomWalkTsG.java

/**
 * @param args the command line arguments
 * @throws java.io.IOException/*from w  w w  . j  av a  2  s. c  o m*/
 */
public static void main(String[] args) throws IOException, Exception {

    if (args.length < 2) {
        System.err.println("Usage: randomWalkTimeSeriesGenerator <FileName> <TimeSeriesNbr> <TimeSeriesSize>");
        System.exit(1);
    }

    CSVWriter writer = new CSVWriter(new FileWriter(args[0] + "_" + args[1] + "_" + args[2] + ".csv"),
            CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER);

    for (int i = 1; i < Integer.parseInt(args[1]) + 2; i++) {
        String[] ts = randomWalk(Integer.parseInt(args[2]) + 1);
        ts[0] = Integer.toString(i);
        writer.writeNext(ts);
        writer.flushQuietly();
    }
    writer.close();
}