List of usage examples for java.util List add
boolean add(E e);
From source file:Main.java
public static void main(final String[] args) throws Exception { Random RND = new Random(); ExecutorService es = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); List<Future<String>> results = new ArrayList<>(10); for (int i = 0; i < 10; i++) { results.add(es.submit(new TimeSliceTask(RND.nextInt(10), TimeUnit.SECONDS))); }//from w ww. j av a2 s . c om es.shutdown(); while (!results.isEmpty()) { Iterator<Future<String>> i = results.iterator(); while (i.hasNext()) { Future<String> f = i.next(); if (f.isDone()) { System.out.println(f.get()); i.remove(); } } } }
From source file:de.unisb.cs.st.javalanche.mutation.util.CsvWriter.java
public static void main(String[] args) throws IOException { // Set<Long> covered = MutationCoverageFile.getCoveredMutations(); // List<Long> mutationIds = QueryManager.getMutationsWithoutResult( // covered, 0); Session session = HibernateUtil.getSessionFactory().openSession(); List<Mutation> mutations = QueryManager.getMutationsForProject( ConfigurationLocator.getJavalancheConfiguration().getProjectPrefix(), session); logger.info("Got " + mutations.size() + " mutation ids."); List<String> lines = new ArrayList<String>(); lines.add(Mutation.getCsvHead() + ",DETECTED"); int counter = 0; int flushs = 0; StopWatch stp = new StopWatch(); for (Mutation mutation : mutations) { // Mutation mutation = QueryManager.getMutationByID(id, session); lines.add(mutation.getCsvString() + "," + mutation.isKilled()); counter++;/*from w w w . j ava 2 s .c o m*/ if (counter > 20) { counter = 0; // 20, same as the JDBC batch size // flush a batch of inserts and release memory: // see // http://www.hibernate.org/hib_docs/reference/en/html/batch.html stp.reset(); stp.start(); flushs++; session.flush(); // session.clear(); logger.info("Did flush. It took: " + DurationFormatUtils.formatDurationHMS(stp.getTime())); } } session.close(); logger.info("Starting to write file with " + lines.size() + " entries."); FileUtils.writeLines(new File("mutations.csv"), lines); }
From source file:Main.java
public static void main(String[] args) { Main testJFrame = new Main(); List<String> columns = new ArrayList<String>(); List<String[]> values = new ArrayList<String[]>(); columns.add("col1"); columns.add("col2"); columns.add("col3"); for (int i = 0; i < 100; i++) { values.add(new String[] { "val" + i + " col1", "val" + i + " col2", "val" + i + " col3" }); }/*from w w w . j av a 2 s. com*/ TableModel tableModel = new DefaultTableModel(values.toArray(new Object[][] {}), columns.toArray()); JTable table = new JTable(tableModel); testJFrame.setLayout(new BorderLayout()); testJFrame.add(new JScrollPane(table), BorderLayout.CENTER); testJFrame.add(table.getTableHeader(), BorderLayout.NORTH); testJFrame.setVisible(true); testJFrame.setSize(200, 200); }
From source file:Main.java
public static void main(String[] args) throws InterruptedException { ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1); List<Particle> allTheParticles = new ArrayList<>(); for (int i = 0; i < 20; i++) { allTheParticles.add(new Particle(i, allTheParticles)); }/*from w w w . j a va2 s. co m*/ while (true) { executor.invokeAll(allTheParticles); executor.invokeAll(allTheParticles); } }
From source file:SortByMark.java
public static void main(String args[]) { List<Student> students = new ArrayList<Student>(); SortByMark sortByMark = new SortByMark(); students.add(new Student("A", new Double(34.34))); students.add(new Student("C", new Double(123.22))); students.add(new Student("B", new Double(13.00))); students.add(new Student("Z", new Double(99.22))); students.add(new Student("X", new Double(-19.08))); Collections.sort(students, sortByMark); for (Student student : students) { System.out.println(student); }/*www . j ava 2 s .co m*/ }
From source file:com.ywh.train.Test.java
public static void main(String[] args) throws Exception { List<NameValuePair> parameters = new ArrayList<NameValuePair>(); parameters.add(new BasicNameValuePair("includeStudent", "00")); parameters.add(new BasicNameValuePair("orderRequest.from_station_telecode", "SHH")); parameters.add(new BasicNameValuePair("orderRequest.start_time_str", "00:00--24:00")); parameters.add(new BasicNameValuePair("orderRequest.to_station_telecode", "CSQ")); parameters.add(new BasicNameValuePair("orderRequest.train_date", "2011-11-24")); parameters.add(new BasicNameValuePair("orderRequest.train_no", "")); parameters.add(new BasicNameValuePair("seatTypeAndNum", "")); parameters.add(new BasicNameValuePair("trainClass", "QB#D#Z#T#K#QT#")); parameters.add(new BasicNameValuePair("trainPassType", "QB")); String responseBody = "0,<span id='id_5l0000D10502' class='base_txtdiv' onmouseover=javascript:onStopHover('5l0000D10502#AOH#CSQ') onmouseout='onStopOut()'>D105</span>,<img src='/otsweb/images/tips/first.gif'> <br> 09:08,<img src='/otsweb/images/tips/last.gif'> <br> 18:21,09:13,--,--,<font color='darkgray'></font>,<font color='#008800'></font>,--,--,--,--,--,--,--,<input type='button' class='yuding_u' onmousemove=this.className='yuding_u_over' onmousedown=this.className='yuding_u_down' onmouseout=this.className='yuding_u' onclick=javascript:getSelected('D105#553#09:08#5l0000D10502#AOH#CSQ') value=''></input>," + "<span id='id_5l0000D10502' class='base_txtdiv' onmouseover=javascript:onStopHover('5l0000D10502#EPH#PXG') onmouseout='onStopOut()'>D105</span>, ? <br> 09:38, ?? <br> 17:09,07:31,--,--,<font color='darkgray'></font>,<font color='darkgray'></font>,--,--,--,--,--,--,--,<input type='button' class='yuding_x' value=''></input>"; List<TrainQueryInfo> tqis = Util.parserQueryInfo(responseBody); for (TrainQueryInfo tqi : tqis) { System.out.println(tqi);/*from www. ja va2 s .c o m*/ } String citys = "@bji||BJP|0@bjn|?|VNP|1@bjx||BXP|2@cqb|?|CUW|3@sha||SHH|4@shn|?|SNH|5@shq||AOH|6@shx||SXH|7@tji||TJP|8@tjn|?|TIP|9@tjx||TXP|10@cch||CCT|11@cdd|?|ICW|12@cdu|?|CDW|13@csh||CSQ|14@csn|?|CWQ|15@fzh|?|FZS|16@fzn|??|FYS|17@gzb||GBQ|18@gzd||GGQ|19@gzh||GZQ|20@gzn|?|IZQ|21@heb||HBB|22@hfe|?|HFH|23@hkd|?|HMQ|24@hko|?|VUQ|25@hzh|?|HZH|26@hzn|??|XHH|27@jna|?|JNK|28@jnd|?|JAK|29@jnx|?|JGK|30@lzh||LZJ|31@nch|?|NCG|32@nji|?|NJH|33@njn|??|NKH|34@sjb||VVP|35@sjz||SJP|36@sya||SYT|37@syb||SBT|38@tyu||TYV|39@wha||WHN|40@xab||EAY|41@xan||XAY|42@zzh||ZZF|43@aya||AYF|44@bbu||BBH|45@bji|?|BJY|46@cna|??|CEH|47@czh||CZH|48@djy||DDW|49@dli||DLT|50@dsq||DQT|51@dzh||RXW|52@fdi|?|FES|53@han||AUH|54@hda||HDP|55@hko|?|HKN|56@hnx|?|EUH|57@hsh||HSP|58@hsh||HSN|59@jan|?|VAG|60@jgs||JGG|61@jhx|?|JBH|62@jji|?|JJG|63@jli|?|JLL|64@jsh||JUH|65@kfe|?|KFF|66@ksn|?|KNH|67@lan||UAH|68@lhe||LON|69@ljy|?|LKP|70@lym||LLF|71@lzh||LZD|72@nbd|?|NVH|73@nch|?|NCW|74@nto|?|NUH|75@pxi|??|PXG|76@pxx||PCW|77@qcs|?|QSW|78@qda|?|QDK|79@qzh||QEH|80@qzh||QYS|81@shg||SHD|82@sni|??|NIW|83@spi||SPT|84@sqi||SQF|85@sra||SRG|86@sya|??|SNN|87@sya||SEQ|88@szh|?|SZN|89@szh|?|SZH|90@szh||SZQ|91@tgu||TGP|92@tli|?|TLT|93@tsb|?|FUP|94@tsh|?|TSP|95@wch||WCN|96@wfd||WDT|97@wna|?|WNY|98@wxi||WXH|99@wys||WAS|100@wzn|?|VRH|101@xch||XCF|102@xhu||EFQ|103@xmb||XKS|104@xme||XMS|105@xxi||XXF|106@xya||XUN|107@xya||XFN|108@xyu||XUG|109@xzh|?|XCH|110@yan||YWY|111@ych|?|AFH|112@ych||YCG|113@yta||YTG|114@ywu||YWH|115@yxi||YON|116@yzh||YLH|117@zbo|?|ZBK|118@zhb|?|ZIQ|119@zji||ZJH|120@zmd||ZDN|121@zzh||ZZQ|122@zzh||ZEK|123@zzx||ZFK|124@aji||ARH|125@atb||ASH|126@bao|?|BWQ|127@bbn|?|BMH|128@bdh||BEP|129@bdi|?|BDP|130@bhs|??|BWH|131@bji||IBQ|132@bji||BLQ|133@cbb|?|CIN|134@cle|?|CLK|135@czb||ESH|136@czh|?|CXH|137@czx||ICQ|138@czx||CBP|139@dan||DAG|140@dgu||DAQ|141@dsh|?|DRQ|142@dtu||RUH|143@dya||DYH|144@dyb||EXH|145@dyd||IAW|146@dyu||EWH|147@dzd||DIP|148@dzh||DXP|149@ezh||ECN|150@fan|?|FAS|151@fdo||FIH|152@fhu||FHH|153@fqi|?|FQS|154@gmi||GMK|155@gqc|?|GAG|156@gyn|?|GYF|157@gzh|?|GNQ|158@hax||HIH|159@hax||VXN|160@hch|??|WKW|161@hgz||IGW|162@hji||HJS|163@hlb||HPD|164@hni|?|HNH|165@hqi||VQH|166@hsb|?|HDY|167@hsh||VCH|168@hsx||HEQ|169@hyd||HVQ|170@hzh||VON|171@jji||JJS|172@jme||JWQ|173@jsb||EGH|174@jsn|?|EAH|175@jxi||JXH|176@jxn|?|EPH|177@jzb||JZK|178@jzh||JZH|179@jzn|?|JOD|180@lbx|??|LPF|181@lch|?|UCK|182@lfa|?|LJP|183@lha||UFH|184@lji||LKS|185@lsh|?|LSG|186@lsh||LIQ|187@lxi||UXP|188@lyo||LMH|189@lyu|?|LVS|190@lyx||LPQ|191@mcb||MBN|192@mcn|?|MNF|193@mla||MHQ|194@mld||MQQ|195@nde|?|NES|196@nha|?|NHH|197@nla|?|NNQ|198@nxb|?|NEH|199@pjb||PBD|200@pti||PTS|201@qfd||QAK|202@qha|?|QYQ|203@qji||INH|204@qsy||QYH|205@qyu||QBQ|206@qzs|?|QZK|207@ran||RAH|208@rch||RCG|209@rgu||RUQ|210@sde||ORQ|211@sfa|?|OLH|212@sgu||SNQ|213@sjn|??|IMH|214@slo||SLQ|215@smn|?|SCF|216@smx||OQH|217@sxi|?|SOH|218@syu||BDH|219@szb||SND|220@szb|?|OHH|221@szd||SRH|222@szq|?|ITH|223@szq|?|KAH|224@tan|?|TID|225@tan||TMK|226@tms||TLS|227@tna|?|TVW|228@txi|?|TCH|229@tzd||TEK|230@tzh|?|TZH|231@wch||WEQ|232@wfa|??|WFK|233@wli||VHH|234@wnb|?|WBY|235@wni|?|WNQ|236@wqi||WWP|237@wxd||WGH|238@wxq||IFH|239@xga|?|XGN|240@xla|?|EAQ|241@xli||XPH|242@xnb|?|XRN|243@xpu||XOS|244@xpu||XIW|245@xta|?|XTP|246@xzd|?|UUH|247@ych||AIH|248@yds|??|YGH|249@yha|?|EVH|250@yji||URH|251@ylw||TWQ|252@ylz|?|YSY|253@yqb||YPP|254@yqi|?|UPH|255@yxi||ACG|256@yya||YYH|257@yyd||YIQ|258@zji||ZDH|259@zjn|?|ZEH|260@zmt||ZOQ|261@zqi||ZTK|262@zsb||ZGQ|263@zsh||ZSQ|264@zzx||ZAQ|265"; String city[] = citys.split("@"); System.out.println("---------start--------"); for (String tmp : city) { System.out.println(tmp); } System.out.println("---------end--------"); //String test = "? ? ?? ? ? ? ? --> ?? ??? : 260.0()--> ? Sat Nov 26 14:04:16 CST 2011 1 ? ?? ? ? Mon Nov 28 00:00:00 CST 2011 D105 Thu Jan 01 09:08:00 CST 1970 02 052 ?, 260.0 ? --> --> ??"; String test = "1 vxv"; System.out.println(test.replaceAll("\\s", "")); }
From source file:com.xue777hua.emails.test.Test.java
public static void main(String[] args) { String text = "<div id=\"frag_1\" class=\"page_fragment auth_frag\" data-first=\"true\" data-fid=\"1\"><div class=\"module_topic_paths\"></div><h1 class=\"svTitle\" id=\"tm005\">Effect of inulin and pectin on rheological and thermal properties of potato starch paste and gel</h1><ul class=\"authorGroup noCollab\"><li><a href=\"#\" class=\"authorName\" id=\"authname_N41d730a0N3ee493d4\" data-t=\"a\" data-fn=\"Teresa\" data-ln=\"Witczak\" data-pos=\"1\" data-tb=\"\">Teresa Witczak</a><a title=\"Affiliation: a\" href=\"#af005\" class=\"intra_ref auth_aff\" id=\"baf005\"><sup>a</sup></a><sup>, </sup><a title=\"Corresponding author contact information\" href=\"#cor1\" id=\"bcor1\" class=\"intra_ref auth_corr\"><img class=\"imgLazyJSB\" alt=\"Corresponding author contact information\" src=\"/sd/grey_pxl.gif\" data-inlimg=\"/entities/REcor.gif\"><noscript><img alt=\"Corresponding author contact information\" src=\"http://origin-cdn.els-cdn.com/sd/entities/REcor.gif\"></noscript></a><sup>, </sup><a href=\"mailto:t.witczak@ur.krakow.pl\" class=\"auth_mail\"><img class=\"imgLazyJSB\" src=\"/sd/grey_pxl.gif\" alt=\"E-mail the corresponding author\" data-inlimg=\"/entities/REemail.gif\"><noscript><img src=\"http://origin-cdn.els-cdn.com/sd/entities/REemail.gif\" alt=\"E-mail the corresponding author\"></noscript></a>, </li><li><a href=\"#\" class=\"authorName\" id=\"authname_N41d730a0N3ee4953c\" data-t=\"a\" data-fn=\"Mariusz\" data-ln=\"Witczak\" data-pos=\"2\" data-tb=\"\">Mariusz Witczak</a><a title=\"Affiliation: a\" href=\"#af005\" class=\"intra_ref auth_aff\" id=\"baf005\"><sup>a</sup></a>, </li><li><a href=\"#\" class=\"authorName\" id=\"authname_N41d730a0N3ee495f0\" data-t=\"a\" data-fn=\"Rafał\" data-ln=\"Ziobro\" data-pos=\"3\" data-tb=\"\">Rafa Ziobro</a><a title=\"Affiliation: b\" href=\"#af010\" class=\"intra_ref auth_aff\" id=\"baf010\"><sup>b</sup></a></li></ul><!--VALIDHTML--><ul class=\"affiliation\"><li id=\"af005\"><sup>a</sup> <span id=\"\">Department of Engineering and Machinery for Food Industry, University of Agriculture in Krakow, Balicka 122 Str., 30-149 Krakow, Poland</span></li><li id=\"af010\"><sup>b</sup> <span id=\"\">Department of Carbohydrates Technology, University of Agriculture in Krakow, Balicka 122 Str., 30-149 Krakow, Poland</span></li></ul><!--VALIDHTML--><!--VALIDHTML--><dl class=\"articleDates\"><dd>Received 24 May 2013, Revised 1 October 2013, Accepted 1 October 2013, Available online 11 October 2013</dd></dl><!--VALIDHTML--><div class=\"moreInformation\"></div><div id=\"ppvPlaceHolder\" class=\"hidden\"></div><!--VALIDHTML--><div id=\"showMoreButtons\"></div><dl class=\"extLinks\"><dd class=\"doiLink\"></dd><dd class=\"rightsLink\"></dd></dl><div class=\"articleOAlabelForced\"></div><div id=\"refersToAndreferredToBy\"><dl id=\"referredToBy\" class=\"documentThread\"><!--Referred To By--></dl></div><!--FRAGMENTEND--><div class=\"page_fragment_ind auth_frag\" data-id=\"frag_2\"></div></div>"; String authorList = ""; String articleTitle = ""; // ???title/*from w w w .j a v a2 s .c o m*/ Pattern articleTitlePattern = Pattern.compile("<h1.+?svTitle.+?>(.+?)</h1>"); Matcher articleTitleMatcher = articleTitlePattern.matcher(text); while (articleTitleMatcher.find()) { articleTitle = articleTitleMatcher.group(1); articleTitle = StringEscapeUtils.unescapeHtml(articleTitle); articleTitle = StringUtils.stripTags(articleTitle); System.out.println("" + articleTitle); } // ??? Pattern p = Pattern.compile("<ul.+?authorGroup.+?>(.+?)</ul>"); Matcher m = p.matcher(text); while (m.find()) { authorList = m.group(1); } p = Pattern.compile("<li>(.+?)</li>"); m = p.matcher(authorList); while (m.find()) { String authorItem = m.group(1); if (authorItem.contains("mailto")) { Pattern nameEmailPattern = Pattern .compile("data-tb=\"[\\d]{0,}\">(.+?)</a>.*href=\"mailto:(.+?)\" class=\"auth_mail\">"); Matcher nameEmailMatcher = nameEmailPattern.matcher(authorItem); if (nameEmailMatcher.find()) { String name = nameEmailMatcher.group(1); String email = nameEmailMatcher.group(2); name = StringEscapeUtils.unescapeHtml(name); // ???new ArrayList List<String> fieldList = new ArrayList<String>(); fieldList.add(name); fieldList.add(email); fieldList.add(articleTitle); int hashKey = (name + email + articleTitle).hashCode(); System.out.println("?????TitlehashKey:" + name + "|" + email + "|" + articleTitle + "|" + hashKey + ", nameEmailsList"); } } } }
From source file:ch.rasc.wampspring.demo.client.CallClientSockJs.java
public static void main(String[] args) throws InterruptedException { List<Transport> transports = new ArrayList<>(2); transports.add(new WebSocketTransport(new StandardWebSocketClient())); transports.add(new RestTemplateXhrTransport()); WebSocketClient webSocketClient = new SockJsClient(transports); JsonFactory jsonFactory = new MappingJsonFactory(new ObjectMapper()); CountDownLatch latch = new CountDownLatch(10_000); TestTextWebSocketHandler handler = new TestTextWebSocketHandler(jsonFactory, latch); Long[] start = new Long[1]; ListenableFuture<WebSocketSession> future = webSocketClient.doHandshake(handler, "ws://localhost:8080/wampOverSockJS"); future.addCallback(wss -> {//from ww w . j a v a 2 s . co m start[0] = System.currentTimeMillis(); for (int i = 0; i < 10_000; i++) { CallMessage callMessage = new CallMessage(UUID.randomUUID().toString(), "testService.sum", i, i + 1); try { wss.sendMessage(new TextMessage(callMessage.toJson(jsonFactory))); } catch (Exception e) { System.out.println("ERROR SENDING CALLMESSAGE" + e); latch.countDown(); } } }, t -> { System.out.println("DO HANDSHAKE ERROR: " + t); System.exit(1); }); if (!latch.await(3, TimeUnit.MINUTES)) { System.out.println("SOMETHING WENT WRONG"); } System.out.println((System.currentTimeMillis() - start[0]) / 1000 + " seconds"); System.out.println("SUCCESS: " + handler.getSuccess()); System.out.println("ERROR : " + handler.getError()); }
From source file:org.bigtextml.drivers.BigMapTest.java
public static void main(String[] args) { /*//from w w w. java2 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; //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.dianping.dpsf.other.echo.EchoClient.java
/** * @param args/* ww w . jav a2 s. com*/ * @throws Exception */ public static void main(String[] args) throws Exception { PigeonClientMock.setServiceAddress("127.0.0.1:20001,127.0.0.1:20002"); ApplicationContext ctx = new ClassPathXmlApplicationContext("echo-client.xml"); IEcho s = (IEcho) ctx.getBean("echo"); // System.out.println(s.echo("aa")); // Thread.sleep(3000); // System.out.println(s.echo("aa")); // System.out.println("firing"); Random rnd = new Random(System.currentTimeMillis()); List<String[]> hostList = new ArrayList<String[]>(); hostList.add(new String[] { "127.0.0.1", "20001", "1" }); PigeonClientMock.getSc().onServiceHostChange("http://service.dianping.com/echoService", hostList); int i = 0; while (i < 100) { try { System.out.println(s.echo("aa")); } catch (Exception e) { System.out.println("EEEEEEEEEEEEEEEEEEEEEEE"); } Thread.sleep(2000); if (i == 1) { System.out.println("+++++++++++++++++++adding 20002++++++++++++++++"); hostList = new ArrayList<String[]>(); hostList.add(new String[] { "127.0.0.1", "20001", "1" }); hostList.add(new String[] { "127.0.0.1", "20002", "1" }); PigeonClientMock.getSc().onServiceHostChange("http://service.dianping.com/echoService", hostList); } if (i == 5) { System.out.println("+++++++++++++++++++adding 20003++++++++++++++++"); hostList = new ArrayList<String[]>(); hostList.add(new String[] { "127.0.0.1", "20001", "1" }); hostList.add(new String[] { "192.168.32.111", "20003", "1" }); PigeonClientMock.getSc().onServiceHostChange("http://service.dianping.com/echoService", hostList); } if (i == 10) { System.out.println("--------------------change wt------------"); PigeonClientMock.getSc().onHostWeightChange("127.0.0.1", 2); } i++; } }