List of usage examples for java.util List size
int size();
From source file:com.mtea.macrotea_httpclient_study.ClientCustomContext.java
public final static void main(String[] args) throws Exception { HttpClient httpclient = new DefaultHttpClient(); try {/*from ww w .j a v a 2s. c o m*/ // CookieStore CookieStore cookieStore = new BasicCookieStore(); // HttpContext HttpContext localContext = new BasicHttpContext(); //HttpContextCookieStore localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); HttpGet httpget = new HttpGet("http://www.google.com/"); System.out.println("executing request " + httpget.getURI()); // ? HttpResponse response = httpclient.execute(httpget, localContext); HttpEntity entity = response.getEntity(); System.out.println("----------------------------------------"); System.out.println(response.getStatusLine()); if (entity != null) { System.out.println("Response content length: " + entity.getContentLength()); } //???cookie List<Cookie> cookies = cookieStore.getCookies(); for (int i = 0; i < cookies.size(); i++) { System.out.println("Local cookie: " + cookies.get(i)); } // EntityUtils.consume(entity); System.out.println("----------------------------------------"); } finally { //??httpclient??? httpclient.getConnectionManager().shutdown(); } }
From source file:com.gargoylesoftware.htmlunit.source.TestCaseCreator.java
/** * The entry point.//from ww w.ja v a2s . co m * * @param args the arguments * @throws IOException if an error occurs */ public static void main(final String[] args) throws IOException { if (args.length == 0) { System.out.println("HTML file location is not provided"); return; } final File file = new File(args[0]); if (!file.exists()) { System.out.println("File does not exist " + file.getAbsolutePath()); } System.out.println(" /**"); System.out.println(" * @throws Exception if an error occurs"); System.out.println(" */"); System.out.println(" @Test"); System.out.println(" @Alerts()"); System.out.println(" public void test() throws Exception {"); final List<String> lines = FileUtils.readLines(file, TextUtil.DEFAULT_CHARSET); for (int i = 0; i < lines.size(); i++) { final String line = lines.get(i); if (i == 0) { System.out.println(" final String html = \"" + line.replace("\"", "\\\"") + "\\n\""); } else { System.out.print(" + \"" + line.replace("\"", "\\\"") + "\\n\""); if (i == lines.size() - 1) { System.out.print(";"); } System.out.println(); } } System.out.println(" loadPageWithAlerts2(html);"); System.out.println(" }"); }
From source file:Main.java
public static void main(String[] args) { List<String> aList = new ArrayList<String>(); Map<Integer, String> aMap = new HashMap<Integer, String>(); aList.add("A"); aList.add("B"); for (int i = 0; i < aList.size(); i++) { aMap.put(i + 1, aList.get(i));/*from w w w . java 2 s.c o m*/ } System.out.println(aMap.toString()); }
From source file:io.mapzone.arena.csw.GetProposalsRequest.java
/** * Test.//from w w w. jav a 2s. c o m */ public static void main(String[] args) throws Exception { GetProposalsRequest getProposals = new GetProposalsRequest().constraint.put("test").baseUrl .put("http://localhost:8090/csw"); List<String> rs = getProposals.execute(new NullProgressMonitor()); System.out.println("Results:" + rs.size()); System.out.println(rs); }
From source file:MainClass.java
public static void main(String args[]) { String simpsons[] = { "B", "H", "L", "M", "H", "M", "R" }; List list = new ArrayList(Arrays.asList(simpsons)); // Ensure list sorted Collections.sort(list);/* w ww. ja va 2 s .c o m*/ System.out.println("Sorted list: [length: " + list.size() + "]"); System.out.println(list); // Search for element in list int index = Collections.binarySearch(list, "M"); System.out.println("Found M @ " + index); // Search for element not in list index = Collections.binarySearch(list, "J"); System.out.println("Didn't find J @ " + index); }
From source file:com.welty.novello.coca.RandGameMvSource.java
/** * Select s8rXX, non-anti, games from the file ~/dev/novello/Othello/latest.223270.bz2 *//*from w ww . j av a2s . c o m*/ public static void main(String[] args) throws IOException, CompressorException { final List<MeValue> mvs = new RandGameMvSource().getMvs(); System.out.format("%,d total positions", mvs.size()); int nPrinted = 0; for (MeValue mv : mvs) { if (Math.abs(mv.value) > 2000 && mv.nEmpty() < 3) { System.out.println(mv); nPrinted++; } if (nPrinted > 100) { break; } } }
From source file:elaborate.editor.backend.Indexer.java
@SuppressWarnings("boxing") public static void main(String[] args) { boolean wipeIndexFirst = args.length == 0 ? false : "-w".equals(args[0]); StopWatch sw = new StopWatch(); sw.start();//w w w. j a va2s. c o m ElaborateSolrIndexer solr = new ElaborateSolrIndexer(); if (wipeIndexFirst) { Log.info("clearing index"); solr.clear(); } EntityManager entityManager = HibernateUtil.getEntityManager(); try { ProjectEntryService projectEntryService = ProjectEntryService.instance(); projectEntryService.setEntityManager(entityManager); List<ProjectEntry> projectentries = projectEntryService.getAll(); int size = projectentries.size(); Log.info("indexing {} projectEntries", size); int n = 1; for (ProjectEntry projectEntry : projectentries) { Log.info("indexing projectEntry {} ({}/{} = {}%) (est. time remaining: {})", // new Object[] { // projectEntry.getId(), n, size, // percentage(n, size), // time_remaining(n, size, sw.getTime()) // } // ); solr.index(projectEntry, autoCommit(n)); n++; } } finally { entityManager.close(); } solr.commit(); sw.stop(); Log.info("done in {}", convert(sw.getTime())); }
From source file:Main.java
public static void main(String args[]) { List<Integer> dataList = new ArrayList<Integer>(); for (int i = 0; i < 10; i++) { dataList.add(i);// w w w . ja v a 2 s.co m } Collections.shuffle(dataList); int[] num = new int[dataList.size()]; for (int i = 0; i < dataList.size(); i++) { num[i] = dataList.get(i); } System.out.println(Arrays.toString(num)); }
From source file:de.tudarmstadt.ukp.experiments.argumentation.clustering.entropy.MatrixExperiments.java
public static void main(String[] args) throws Exception { File in = new File(args[0]); List<String> lines = IOUtils.readLines(new FileInputStream(in)); int rows = lines.size(); int cols = lines.iterator().next().split("\\s+").length; double[][] matrix = new double[rows][cols]; Map<Integer, Double> clusterEntropy = new HashMap<>(); for (int i = 0; i < rows; i++) { String line = lines.get(i); String[] split = line.split("\\s+"); for (int j = 0; j < split.length; j++) { Double value = Double.valueOf(split[j]); matrix[i][j] = value;/*from w w w . ja v a 2s . co m*/ } // entropy of the cluster Vector v = new DenseVector(matrix[i]); // System.out.print(VectorUtils.entropy(v)); double entropy = VectorUtils.entropy(VectorUtils.normalize(v)); System.out.print(entropy); System.out.print(" "); clusterEntropy.put(i, entropy); } Map<Integer, Double> sorted = sortByValue(clusterEntropy); System.out.println(sorted); HeatChart map = new HeatChart(matrix); // Step 2: Customise the chart. map.setTitle("This is my heat chart title"); map.setXAxisLabel("X Axis"); map.setYAxisLabel("Y Axis"); // Step 3: Output the chart to a file. map.saveToFile(new File("/tmp/java-heat-chart.png")); }
From source file:Main.java
public static void main(String[] a) { List<String> list = new LinkedList<String>(); list.add("A"); list.add("B"); list.add("C"); list.add("D"); ListIterator<String> iter = list.listIterator(list.size()); while (iter.hasPrevious()) { System.out.println(iter.previous()); iter.add("a"); break;//from w w w. jav a2 s . c o m } System.out.println(list); }