List of usage examples for java.util List size
int size();
From source file:com.dianping.wed.cache.redis.util.TestDataUtil.java
public static void main(String[] args) { // ????/* w w w . j a v a 2s . c o m*/ //&method=incr¶meterTypes=com.dianping.wed.cache.redis.dto.WeddingRedisKeyDTO¶meters={"category":"justtest","params":["1","2"]} List<String> opList = new ArrayList<String>(opAndKey.keySet()); for (int i = 0; i < 1000; i++) { int index = RandomUtils.nextInt(opList.size()); String op = opList.get(index); String key = opAndKey.get(op); StringBuilder result = new StringBuilder(); int params = buildTestUrl(result, op, key); String fileName = "/Users/Bob/Desktop/data/data-" + params + ".csv"; try { //kuka.txt //kuka.txt FileWriter writer = new FileWriter(fileName, true); writer.write(result.toString()); writer.close(); } catch (IOException e) { e.printStackTrace(); } } System.out.println("done"); }
From source file:AllFieldsSnippet.java
public static void main(String[] args) { Object obj = new Object(); //start extract AllFieldsSnippet Class cls = obj.getClass();/*www. ja v a 2 s . c o m*/ List accum = new LinkedList(); while (cls != null) { Field[] f = cls.getDeclaredFields(); for (int i = 0; i < f.length; i++) { accum.add(f[i]); } cls = cls.getSuperclass(); } Field[] allFields = (Field[]) accum.toArray(new Field[accum.size()]); //stop extract AllFieldsSnippet }
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 w w. ja v a 2s . c o m 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:AmazonKinesisSample.java
public static void main(String[] args) throws Exception { init();/*from w w w . j av a 2 s. c o m*/ final String myStreamName = "myFirstStream"; final Integer myStreamSize = 1; // Create a stream. The number of shards determines the provisioned throughput. CreateStreamRequest createStreamRequest = new CreateStreamRequest(); createStreamRequest.setStreamName(myStreamName); createStreamRequest.setShardCount(myStreamSize); kinesisClient.createStream(createStreamRequest); // The stream is now being created. LOG.info("Creating Stream : " + myStreamName); waitForStreamToBecomeAvailable(myStreamName); // list all of my streams ListStreamsRequest listStreamsRequest = new ListStreamsRequest(); listStreamsRequest.setLimit(10); ListStreamsResult listStreamsResult = kinesisClient.listStreams(listStreamsRequest); List<String> streamNames = listStreamsResult.getStreamNames(); while (listStreamsResult.isHasMoreStreams()) { if (streamNames.size() > 0) { listStreamsRequest.setExclusiveStartStreamName(streamNames.get(streamNames.size() - 1)); } listStreamsResult = kinesisClient.listStreams(listStreamsRequest); streamNames.addAll(listStreamsResult.getStreamNames()); } LOG.info("Printing my list of streams : "); // print all of my streams. if (!streamNames.isEmpty()) { System.out.println("List of my streams: "); } for (int i = 0; i < streamNames.size(); i++) { System.out.println(streamNames.get(i)); } LOG.info("Putting records in stream : " + myStreamName); // Write 10 records to the stream for (int j = 0; j < 10; j++) { PutRecordRequest putRecordRequest = new PutRecordRequest(); putRecordRequest.setStreamName(myStreamName); putRecordRequest.setData(ByteBuffer.wrap(String.format("testData-%d", j).getBytes())); putRecordRequest.setPartitionKey(String.format("partitionKey-%d", j)); PutRecordResult putRecordResult = kinesisClient.putRecord(putRecordRequest); System.out.println("Successfully putrecord, partition key : " + putRecordRequest.getPartitionKey() + ", ShardID : " + putRecordResult.getShardId()); } // Delete the stream. LOG.info("Deleting stream : " + myStreamName); DeleteStreamRequest deleteStreamRequest = new DeleteStreamRequest(); deleteStreamRequest.setStreamName(myStreamName); kinesisClient.deleteStream(deleteStreamRequest); // The stream is now being deleted. LOG.info("Stream is now being deleted : " + myStreamName); }
From source file:com.cazcade.billabong.store.impl.CloudFilesBasedBinaryStore.java
public static void main(String[] args) throws Exception { FilesClient client = new FilesClient(System.getProperty("cloudfiles.username"), System.getProperty("cloudfiles.apikey")); boolean loggedin = client.login(); if (loggedin) { System.out.println("Logged in."); List<FilesContainer> containers = client.listContainers(); System.out.println("Container count: " + containers.size()); for (FilesContainer container : containers) { System.out.println("\tContainer: " + container.getName()); }// ww w .ja va 2s .c o m byte[] file = "<html><body>Hello World</body></html>".getBytes("UTF-8"); client.storeObject("public", file, "text/html", "test.html", new HashMap<String, String>()); List<FilesCDNContainer> cdnContainers = client.listCdnContainerInfo(); System.out.println("CDN Container count: " + cdnContainers.size()); for (FilesCDNContainer container : cdnContainers) { System.out.println("\tContainer: " + container.getName()); System.out.println("\tContainer URL: " + container.getCdnURL()); List<FilesObject> contents = client.listObjects(container.getName()); System.out.println("\tFile Count: " + contents.size()); // for (FilesObject fileObject : contents) { // System.out.println("\t\tFile: " + fileObject.getName()); // System.out.println("\t\tContent Type: " + fileObject.getMimeType()); // System.out.println("\t\tModified:" + fileObject.getLastModified()); // } } } }
From source file:gov.nih.nci.cacis.mirth.XSLForMirthFormatter.java
/** * @param args - main method args/* w w w. j a va 2 s . com*/ * @throws IOException - error thrown, if any * @throws URISyntaxException - error thrown, if any */ public static void main(String[] args) throws IOException, URISyntaxException { if (args.length < 2) { LOG.error("Usage: XSLForMirthFormatter <formatted-file-output-dir> <xsl-file-1> <xsl-file-2> ..."); System.exit(1); } final List<String> lst = new ArrayList<String>(Arrays.asList(args)); lst.remove(0); final XSLForMirthFormatter frmtr = new XSLForMirthFormatter(); frmtr.formatXSL(args[0], (String[]) lst.toArray(new String[lst.size()])); }
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.java 2s . c om 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:cu.uci.gws.sdlcrawler.PdfCrawlController.java
public static void main(String[] args) throws Exception { Properties cm = PdfCrawlerConfigManager.getInstance().loadConfigFile(); long startTime = System.currentTimeMillis(); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date = new Date(); System.out.println(dateFormat.format(date)); int numberOfCrawlers = Integer.parseInt(cm.getProperty("sdlcrawler.NumberOfCrawlers")); String pdfFolder = cm.getProperty("sdlcrawler.CrawlPdfFolder"); CrawlConfig config = new CrawlConfig(); config.setCrawlStorageFolder(cm.getProperty("sdlcrawler.CrawlStorageFolder")); config.setProxyHost(cm.getProperty("sdlcrawler.ProxyHost")); if (!"".equals(cm.getProperty("sdlcrawler.ProxyPort"))) { config.setProxyPort(Integer.parseInt(cm.getProperty("sdlcrawler.ProxyPort"))); }/* w w w. j a va 2s . c o m*/ config.setProxyUsername(cm.getProperty("sdlcrawler.ProxyUser")); config.setProxyPassword(cm.getProperty("sdlcrawler.ProxyPass")); config.setMaxDownloadSize(Integer.parseInt(cm.getProperty("sdlcrawler.MaxDownloadSize"))); config.setIncludeBinaryContentInCrawling( Boolean.parseBoolean(cm.getProperty("sdlcrawler.IncludeBinaryContent"))); config.setFollowRedirects(Boolean.parseBoolean(cm.getProperty("sdlcrawler.Redirects"))); config.setUserAgentString(cm.getProperty("sdlcrawler.UserAgent")); config.setMaxDepthOfCrawling(Integer.parseInt(cm.getProperty("sdlcrawler.MaxDepthCrawl"))); config.setMaxConnectionsPerHost(Integer.parseInt(cm.getProperty("sdlcrawler.MaxConnectionsPerHost"))); config.setSocketTimeout(Integer.parseInt(cm.getProperty("sdlcrawler.SocketTimeout"))); config.setMaxOutgoingLinksToFollow(Integer.parseInt(cm.getProperty("sdlcrawler.MaxOutgoingLinks"))); config.setResumableCrawling(Boolean.parseBoolean(cm.getProperty("sdlcrawler.ResumableCrawling"))); config.setIncludeHttpsPages(Boolean.parseBoolean(cm.getProperty("sdlcrawler.IncludeHttpsPages"))); config.setMaxTotalConnections(Integer.parseInt(cm.getProperty("sdlcrawler.MaxTotalConnections"))); config.setMaxPagesToFetch(Integer.parseInt(cm.getProperty("sdlcrawler.MaxPagesToFetch"))); config.setPolitenessDelay(Integer.parseInt(cm.getProperty("sdlcrawler.PolitenessDelay"))); config.setConnectionTimeout(Integer.parseInt(cm.getProperty("sdlcrawler.ConnectionTimeout"))); System.out.println(config.toString()); Collection<BasicHeader> defaultHeaders = new HashSet<>(); defaultHeaders .add(new BasicHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")); defaultHeaders.add(new BasicHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3")); defaultHeaders.add(new BasicHeader("Accept-Language", "en-US,en,es-ES,es;q=0.8")); defaultHeaders.add(new BasicHeader("Connection", "keep-alive")); config.setDefaultHeaders(defaultHeaders); List<String> list = Files.readAllLines(Paths.get("config/" + cm.getProperty("sdlcrawler.SeedFile")), StandardCharsets.UTF_8); String[] crawlDomains = list.toArray(new String[list.size()]); PageFetcher pageFetcher = new PageFetcher(config); RobotstxtConfig robotstxtConfig = new RobotstxtConfig(); RobotstxtServer robotstxtServer = new RobotstxtServer(robotstxtConfig, pageFetcher); CrawlController controller = new CrawlController(config, pageFetcher, robotstxtServer); for (String domain : crawlDomains) { controller.addSeed(domain); } PdfCrawler.configure(crawlDomains, pdfFolder); controller.start(PdfCrawler.class, numberOfCrawlers); DateFormat dateFormat1 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date1 = new Date(); System.out.println(dateFormat1.format(date1)); long endTime = System.currentTimeMillis(); long totalTime = endTime - startTime; System.out.println("Total time:" + totalTime); }
From source file:at.gv.egiz.pdfas.web.client.test.SimpleTest.java
public static void main(String[] args) { try {//from ww w. j av a 2 s. co m FileInputStream fis = new FileInputStream("/home/afitzek/simple.pdf"); byte[] inputData = IOUtils.toByteArray(fis); PDFASSignParameters signParameters = new PDFASSignParameters(); signParameters.setConnector(Connector.JKS); signParameters.setPosition(null); signParameters.setProfile("SIGNATURBLOCK_SMALL_DE"); signParameters.setQRCodeContent("TEST CONTENT"); //signParameters.setKeyIdentifier("test"); PDFASSignRequest request = new PDFASSignRequest(); request.setInputData(inputData); request.setParameters(signParameters); request.setRequestID("SOME TEST ID"); //URL endpoint = new //URL("http://demo.egiz.gv.at/demoportal-pdf_as/wssign?wsdl"); //URL endpoint = new // URL("http://www.buergerkarte.at/pdf-as-extern-4/wssign?wsdl"); String baseUrl = "http://demo.egiz.gv.at/demoportal-pdf_as/services/"; //String baseUrl = "http://localhost:8080/pdf-as-web/services/"; //URL endpoint = new URL( // "http://192.168.56.10/pdf-as-web/wssign?wsdl"); URL signEndpoint = new URL(baseUrl + "wssign?wsdl"); URL verifyEndpoint = new URL(baseUrl + "wsverify?wsdl"); RemotePDFSigner signer = new RemotePDFSigner(signEndpoint, true); RemotePDFVerifier verifier = new RemotePDFVerifier(verifyEndpoint, true); PDFASSignRequest signrequest = new PDFASSignRequest(); signrequest.setInputData(inputData); signrequest.setParameters(signParameters); signParameters.setTransactionId("MYID ...."); System.out.println("Simple Request:"); PDFASSignResponse response = signer.signPDFDokument(signrequest); System.out.println("Sign Error: " + response.getError()); PDFASVerifyRequest verifyRequest = new PDFASVerifyRequest(); verifyRequest.setInputData(response.getSignedPDF()); verifyRequest.setVerificationLevel(VerificationLevel.INTEGRITY_ONLY); PDFASVerifyResponse verifyResponse = verifier.verifyPDFDokument(verifyRequest); List<PDFASVerifyResult> results = verifyResponse.getVerifyResults(); for (int i = 0; i < results.size(); i++) { PDFASVerifyResult result = results.get(i); printVerifyResult(result); } /* * System.out.println("Simple Request:"); byte[] outputFile = * signer.signPDFDokument(inputData, signParameters); * * FileOutputStream fos = new FileOutputStream( * "/home/afitzek/simple_request_signed.pdf"); * fos.write(outputFile); fos.close(); * * System.out.println("Simple Request Obj:"); PDFASSignResponse * response = signer.signPDFDokument(request); * * if (response.getSignedPDF() != null) { FileOutputStream fos2 = * new FileOutputStream( * "/home/afitzek/simple_request_obj_signed.pdf"); * fos2.write(response.getSignedPDF()); fos2.close(); } * * if(response.getError() != null) { System.out.println("ERROR: " + * response.getError()); } */ /* List<PDFASSignRequest> bulk = new ArrayList<PDFASSignRequest>(); for (int i = 0; i < 10; i++) { bulk.add(request); } PDFASBulkSignRequest bulkRequest = new PDFASBulkSignRequest(); bulkRequest.setSignRequests(bulk); for (int j = 0; j < 10; j++) { System.out.println("Bulk Request:"); PDFASBulkSignResponse responses = signer .signPDFDokument(bulkRequest); for (int i = 0; i < responses.getSignResponses().size(); i++) { PDFASSignResponse bulkresponse = responses .getSignResponses().get(i); System.out.println("ID: " + bulkresponse.getRequestID()); if (bulkresponse.getError() != null) { System.out.println("ERROR: " + bulkresponse.getError()); } else { System.out.println("OK"); } } } */ System.out.println("Done!"); } catch (Throwable e) { e.printStackTrace(); } }
From source file:com.grossbart.forbiddenfunction.FFRunner.java
/** * The main entry point./*from w ww . j a va 2 s .c om*/ * * @param args the arguments for this process */ public static void main(String[] args) { List<String> errors = run(args); if (errors.size() > 0) { System.out.println("There were forbidden functions."); for (String err : errors) { System.out.println(err); } } }