List of usage examples for java.lang Integer toString
@HotSpotIntrinsicCandidate public static String toString(int i)
From source file:apidemo.APIDemo.java
public static void main(String[] args) throws InterruptedException, Exception { Random random = new Random(); int uReqFeq = 1; while (uReqFeq < 101) { String strJSON = ObjectToString(new JSMessage((long) random.nextInt(10) + 1, (long) random.nextInt(10) + 11, "msg_" + Integer.toString(uReqFeq))); String res = sendPostJson("http://localhost:9494/api/nsservice/msg", strJSON, 10000); System.out.println("Result: " + res); ++uReqFeq;//from ww w . j a v a 2s . co m } }
From source file:com.netcore.hsmart.smsconsumers.SmsConsumer555.java
public static void main(String args[]) throws Exception { ExecutorService executor = Executors.newCachedThreadPool(); for (int i = 1; i <= COUNTERS; i++) { Runnable worker = new SmsConsumer555Runnable(Integer.toString(i)); executor.execute(worker);//from w w w. j a v a 2 s .co m } }
From source file:com.tengen.MultiArrayFindTest.java
public static void main(String[] args) throws UnknownHostException { MongoClient client = new MongoClient(); DB db = client.getDB("school"); DBCollection collection = db.getCollection("students"); System.out.println("Find one:"); DBObject one = collection.findOne(); System.out.println(one);/*w ww . j a v a 2 s . c o m*/ System.out.println("\nFind all: "); DBCursor cursor = collection.find().sort(new BasicDBObject("_id", 1)); System.out.println(cursor.count()); try { while (cursor.hasNext()) { int id = (Integer) cursor.next().get("_id"); //String s = cursor.next().get("name"); Map<Integer, String> myMap = new HashMap<Integer, String>(); BasicBSONList bl = (BasicBSONList) cursor.next().get("scores"); for (Object bo : bl) { BasicBSONObject bo1 = (BasicBSONObject) bo; System.out.println(bo); System.out.println(Integer.toString(id)); if (1 > 1) { } double total1 = Double.parseDouble(bo1.get("score").toString()); System.out.println("score1: " + total1); myMap.put(id, bo1.get("score").toString()); System.out.println("score: " + myMap.get(id)); double total = Double.parseDouble(myMap.get(id).toString()); System.out.println("score: " + total); //} } } } finally { cursor.close(); } System.out.println("\nCount:"); long count = collection.count(); System.out.println(count); }
From source file:TableSortTwoDirection.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() }; }// ww w . j av a 2 s . co m // create a virtual table to display data Display display = new Display(); Shell shell = new Shell(display); 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, new Listener() { public void handleEvent(Event 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 = new Listener() { public void handleEvent(Event 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, new Comparator() { public int compare(Object arg0, Object arg1) { int[] a = (int[]) arg0; int[] b = (int[]) arg1; 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:com.netcore.hsmart.smsconsumers.SmsConsumer558.java
public static void main(String args[]) throws Exception { ExecutorService executor = Executors.newCachedThreadPool(); for (int i = 1; i <= COUNTERS; i++) { Runnable worker = new SmsConsumer558Runnable(Integer.toString(i)); executor.execute(worker);//from ww w . j ava 2 s . c o m } }
From source file:com.netcore.hsmart.smsconsumers.SmsConsumer556.java
public static void main(String args[]) throws Exception { ExecutorService executor = Executors.newCachedThreadPool(); for (int i = 1; i <= COUNTERS; i++) { Runnable worker = new SmsConsumer556Runnable(Integer.toString(i)); executor.execute(worker);//from w w w . ja va 2 s.co m } }
From source file:org.datagator.api.client.SimpleMatrix.java
public static void main(String[] args) throws IOException { FileReader reader = new FileReader("../../data/json/IGO_Weighted_Dyad.json"); SimpleMatrix matrix = (SimpleMatrix) Entity.create(reader); // empty matrix //Matrix matrix = (SimpleMatrix) Entity.create(new java.io.StringReader( // "{\"kind\": \"datagator#SimpleMatrix\", \"columnHeaders\": 0, " + // "\"rowHeaders\": 0, \"rows\": [[]], \"rowsCount\": 1, " + // "\"columnsCount\": 0}")); System.out.println(matrix.kind); System.out.println(Integer.toString(matrix.rowsCount)); System.out.println(Integer.toString(matrix.columnsCount)); }
From source file:com.netcore.hsmart.dlrconsumers.DlrConsumer558.java
public static void main(String args[]) throws Exception { ExecutorService executor = Executors.newCachedThreadPool(); for (int i = 1; i <= COUNTERS; i++) { Runnable worker = new DlrConsumer558Runnable(Integer.toString(i)); executor.execute(worker);/*from w w w .j ava 2s . com*/ } }
From source file:com.athena.peacock.agent.Starter.java
/** * <pre>/*from w w w . j a v a2 s. c o m*/ * * </pre> * @param args */ @SuppressWarnings("resource") public static void main(String[] args) { int rand = (int) (Math.random() * 100) % 50; System.setProperty("random.seconds", Integer.toString(rand)); String configFile = null; try { configFile = PropertyUtil.getProperty(PeacockConstant.CONFIG_FILE_KEY); } catch (Exception e) { // nothing to do. } finally { if (StringUtils.isEmpty(configFile)) { configFile = "/peacock/agent/config/agent.conf"; } } /** * ${peacock.agent.config.file.name} ?? load ? ?? ? ? ? . */ String errorMsg = "\n\"" + configFile + "\" file does not exist or cannot read.\n" + "Please check \"" + configFile + "\" file exists and can read."; Assert.isTrue(AgentConfigUtil.exception == null, errorMsg); Assert.notNull(AgentConfigUtil.getConfig(PeacockConstant.SERVER_IP), "ServerIP cannot be empty."); Assert.notNull(AgentConfigUtil.getConfig(PeacockConstant.SERVER_PORT), "ServerPort cannot be empty."); /** * Agent ID ?? ${peacock.agent.agent.file.name} ? ?, * ?? ? Agent ID ? ?? . */ String agentFile = null; String agentId = null; try { agentFile = PropertyUtil.getProperty(PeacockConstant.AGENT_ID_FILE_KEY); } catch (Exception e) { // nothing to do. } finally { if (StringUtils.isEmpty(agentFile)) { agentFile = "/peacock/agent/.agent"; } } File file = new File(agentFile); boolean isNew = false; if (file.exists()) { try { agentId = IOUtils.toString(file.toURI()); // ? ? agent ID agent ID? ? 36? ? ?. if (StringUtils.isEmpty(agentId) || agentId.length() != 36) { throw new IOException(); } } catch (IOException e) { logger.error(agentFile + " file cannot read or saved invalid agent ID.", e); agentId = PeacockAgentIDGenerator.generateId(); isNew = true; } } else { agentId = PeacockAgentIDGenerator.generateId(); isNew = true; } if (isNew) { logger.info("New Agent-ID({}) be generated.", agentId); try { file.setWritable(true); OutputStreamWriter output = new OutputStreamWriter(new FileOutputStream(file)); output.write(agentId); file.setReadOnly(); IOUtils.closeQuietly(output); } catch (UnsupportedEncodingException e) { logger.error("UnsupportedEncodingException has occurred : ", e); } catch (FileNotFoundException e) { logger.error("FileNotFoundException has occurred : ", e); } catch (IOException e) { logger.error("IOException has occurred : ", e); } } // Spring Application Context Loading logger.debug("Starting application context..."); AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext( "classpath:spring/context-*.xml"); applicationContext.registerShutdownHook(); }
From source file:com.netcore.hsmart.dlrconsumers.DlrConsumer555.java
public static void main(String args[]) throws Exception { ExecutorService executor = Executors.newCachedThreadPool(); for (int i = 1; i <= COUNTERS; i++) { Runnable worker = new DlrConsumer555Runnable(Integer.toString(i)); executor.execute(worker);// w w w . j ava2 s .c o m } }