List of usage examples for java.util List isEmpty
boolean isEmpty();
From source file:Main.java
public static void main(String[] a) { List list = Arrays.asList(new String[] { "A", "B", "C", "D" }); System.out.println(list.size()); System.out.println(list.isEmpty()); }
From source file:com.github.stagirs.lingvo.build.SyntaxStatisticsBuilder.java
public static void main(String[] args) throws Exception { TObjectIntHashMap<String> map = new TObjectIntHashMap<String>(); for (String line : FileUtils.readLines(new File("annot.opcorpora.no_ambig.plain"), "utf-8")) { List<String> types = types(Annotation.parse(line)); if (types.isEmpty()) { continue; }/*from ww w . j a v a 2s . c o m*/ map.adjustOrPutValue(types.get(0), 1, 1); map.adjustOrPutValue(" " + types.get(0), 1, 1); for (int i = 1; i < types.size(); i++) { map.adjustOrPutValue(types.get(i), 1, 1); map.adjustOrPutValue(types.get(i - 1) + " " + types.get(i), 1, 1); } map.adjustOrPutValue(types.get(types.size() - 1) + " ", 1, 1); } final List<String> result = new ArrayList<String>(); map.forEachEntry(new TObjectIntProcedure<String>() { @Override public boolean execute(String key, int count) { result.add(key + "\t" + count); return true; } }); FileUtils.writeLines(new File("src/main/resources/SyntaxStatistics"), "utf-8", result); }
From source file:com.rdsic.pileconstructionmanagement.test.Test.java
public static void main(String[] args) { String sql = "select * from user"; List<Map<String, Object>> list = (ArrayList) GenericHql.INSTANCE.querySQL(sql, 20); if (!list.isEmpty()) { System.out.println("cnt:" + list.size()); JSONObject r = new JSONObject(); r.put("items", list); System.out.println(r.toString()); list.stream().map((item) -> { System.out.println("RECORD"); return item; }).forEach((item) -> {//from w w w.j a va 2s. co m for (String k : item.keySet()) { JSONObject j = new JSONObject(item); System.out.println(j.toString()); System.out.println(StringUtils.rightPad(k, 20, " ") + item.get(k).toString()); } }); } System.exit(0); }
From source file:cn.anthony.util.ClientFormLogin.java
public static void main(String[] args) throws Exception { BasicCookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); try {/*from w ww.j a va 2s . c o m*/ HttpGet httpget = new HttpGet("https://someportal/"); CloseableHttpResponse response1 = httpclient.execute(httpget); try { HttpEntity entity = response1.getEntity(); System.out.println("Login form get: " + response1.getStatusLine()); EntityUtils.consume(entity); System.out.println("Initial set of cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response1.close(); } HttpUriRequest login = RequestBuilder.post().setUri(new URI("https://someportal/")) .addParameter("IDToken1", "username").addParameter("IDToken2", "password").build(); CloseableHttpResponse response2 = httpclient.execute(login); try { HttpEntity entity = response2.getEntity(); System.out.println("Login form get: " + response2.getStatusLine()); EntityUtils.consume(entity); System.out.println("Post logon cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response2.close(); } } finally { httpclient.close(); } }
From source file:com.lxf.spider.client.ClientFormLogin.java
public static void main(String[] args) throws Exception { BasicCookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); try {/* w w w . j ava 2s .co m*/ HttpGet httpget = new HttpGet("http://127.0.0.1:8080/pdqx.jc.web"); CloseableHttpResponse response1 = httpclient.execute(httpget); try { HttpEntity entity = response1.getEntity(); System.out.println("Login form get: " + response1.getStatusLine()); EntityUtils.consume(entity); System.out.println("Initial set of cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response1.close(); } HttpUriRequest login = RequestBuilder.post().setUri(new URI("http://127.0.0.1:8080/pdqx.jc.web")) .addParameter("IDToken1", "username").addParameter("IDToken2", "password").build(); CloseableHttpResponse response2 = httpclient.execute(login); try { HttpEntity entity = response2.getEntity(); System.out.println("Login form get: " + response2.getStatusLine()); EntityUtils.consume(entity); System.out.println("Post logon cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response2.close(); } } finally { httpclient.close(); } }
From source file:com.SSOserver.common.ClientFormLogin.java
public static void main(String[] args) throws Exception { BasicCookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); try {//from w w w. ja v a 2s . com HttpGet httpget = new HttpGet("http://127.0.0.1:8080/SSOserver/Userlogin.action"); CloseableHttpResponse response1 = httpclient.execute(httpget); try { HttpEntity entity = response1.getEntity(); System.out.println("?Login form get: " + response1.getStatusLine()); EntityUtils.consume(entity); System.out.println("? cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("?- " + cookies.get(i).toString()); } } } finally { response1.close(); } // params.add(new BasicNameValuePair("username", "1")); // params.add(new BasicNameValuePair("userpwd", "1")); HttpUriRequest login = RequestBuilder.post() .setUri(new URI("http://127.0.0.1:8080/SSOserver/Userlogin.action")) .addParameter("username", "1").addParameter("userpwd", "1").build(); CloseableHttpResponse response2 = httpclient.execute(login); try { HttpEntity entity = response2.getEntity(); System.out.println("Login form get: " + response2.getStatusLine()); EntityUtils.consume(entity); System.out.println("?Post logon cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("?- " + cookies.get(i).toString()); } } } finally { response2.close(); } } finally { httpclient.close(); } }
From source file:br.gov.lexml.swing.spellchecker.SpellcheckerMain.java
public static void main(String[] args) { try {//from ww w .ja va 2 s . c om System.out.println("Preparando diretrio"); File baseDir = new File("target/spellchecker"); if (!baseDir.isDirectory()) { baseDir.mkdirs(); } Spellchecker s = SpellcheckerFactory.getInstance().createSpellchecker(baseDir); System.out.println("Hunspell library and dictionary loaded"); String words[] = { "subnutido", "isso", "nao" }; for (int i = 0; i < words.length; i++) { String word = words[i]; if (s.misspelled(word)) { List<String> suggestions = s.suggest(word); print("misspelled: " + word); if (suggestions.isEmpty()) { print("\tNo suggestions."); } else { print("\tTry:"); for (String sug : suggestions) { print(" " + sug); } } println(""); } else { println("ok: " + word); } } } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:com.bhc.test.ClientFormLogin.java
public static void main(String[] args) throws Exception { BasicCookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); URI uri = null;// w ww. j a v a 2 s.c om try { uri = new URIBuilder().setScheme("https").setHost("user.qunar.com").setPath("/captcha/api/image") .setParameter("k", "{en7mni(z").setParameter("p", "ucenter_login") .setParameter("c", "ef7d278eca6d25aa6aec7272d57f0a9a") .setParameter("t", String.valueOf(new Date().getTime())).build(); HttpGet httpget = new HttpGet(uri); CloseableHttpResponse response1 = httpclient.execute(httpget); try { HttpEntity entity = response1.getEntity(); System.out.println("Login form get: " + response1.getStatusLine()); EntityUtils.consume(entity); System.out.println("Initial set of cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response1.close(); } HttpUriRequest login = RequestBuilder.post().setUri(new URI("https://someportal/")) .addParameter("IDToken1", "username").addParameter("IDToken2", "password").build(); CloseableHttpResponse response2 = httpclient.execute(login); try { HttpEntity entity = response2.getEntity(); System.out.println("Login form get: " + response2.getStatusLine()); EntityUtils.consume(entity); System.out.println("Post logon cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response2.close(); } } finally { httpclient.close(); } }
From source file:PostMethodMyExample.java
public static void main(String[] args) throws Exception { BasicCookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); try {/* ww w. j a v a 2 s .c o m*/ HttpGet httpget = new HttpGet("https://portal.sun.com/portal/dt"); CloseableHttpResponse response1 = httpclient.execute(httpget); try { HttpEntity entity = response1.getEntity(); System.out.println("Login form get: " + response1.getStatusLine()); EntityUtils.consume(entity); System.out.println("Initial set of cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response1.close(); } HttpPost httpost = new HttpPost("https://portal.sun.com/amserver/UI/Login?" + "org=self_registered_users&" + "goto=/portal/dt&" + "gotoOnFail=/portal/dt?error=true"); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("IDToken1", "username")); nvps.add(new BasicNameValuePair("IDToken2", "password")); httpost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); CloseableHttpResponse response2 = httpclient.execute(httpost); try { HttpEntity entity = response2.getEntity(); System.out.println("Login form get: " + response2.getStatusLine()); EntityUtils.consume(entity); System.out.println("Post logon cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response2.close(); } } finally { httpclient.close(); } }
From source file:com.hilatest.httpclient.apacheexample.ClientFormLogin.java
public static void main(String[] args) throws Exception { DefaultHttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("https://portal.sun.com/portal/dt"); HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); System.out.println("Login form get: " + response.getStatusLine()); if (entity != null) { entity.consumeContent();/*from w ww .j a v a 2 s .co m*/ } System.out.println("Initial set of cookies:"); List<Cookie> cookies = httpclient.getCookieStore().getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } HttpPost httpost = new HttpPost("https://portal.sun.com/amserver/UI/Login?" + "org=self_registered_users&" + "goto=/portal/dt&" + "gotoOnFail=/portal/dt?error=true"); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("IDToken1", "username")); nvps.add(new BasicNameValuePair("IDToken2", "password")); httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); response = httpclient.execute(httpost); entity = response.getEntity(); System.out.println("Login form get: " + response.getStatusLine()); if (entity != null) { entity.consumeContent(); } System.out.println("Post logon cookies:"); cookies = httpclient.getCookieStore().getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpclient.getConnectionManager().shutdown(); }