List of usage examples for java.util List add
boolean add(E e);
From source file:com.otz.plugin.transport.funnel.FunnelService.java
public static void main(String[] args) { List<String> test = new ArrayList<>(); test.add("1"); test.add("2"); test.add("3"); String result = Observable.from(test).filter(s -> s.equals("4")).first() .onErrorResumeNext(Observable.error(new RuntimeException())).flatMap(s -> { System.out.println(s); return Observable.just(s); }).toBlocking().single();/*from ww w. ja v a2 s . c o m*/ System.out.println(result); }
From source file:com.twitter.bazel.checkstyle.CppCheckstyle.java
public static void main(String[] args) throws IOException { CommandLineParser parser = new DefaultParser(); // create the Options Options options = new Options(); options.addOption(Option.builder("f").required(true).hasArg().longOpt("extra_action_file") .desc("bazel extra action protobuf file").build()); options.addOption(Option.builder("c").required(true).hasArg().longOpt("cpplint_file") .desc("Executable cpplint file to invoke").build()); try {/* www . j a v a 2s . c om*/ // parse the command line arguments CommandLine line = parser.parse(options, args); String extraActionFile = line.getOptionValue("f"); String cpplintFile = line.getOptionValue("c"); Collection<String> sourceFiles = getSourceFiles(extraActionFile); if (sourceFiles.size() == 0) { LOG.fine("No cpp files found by checkstyle"); return; } LOG.fine(sourceFiles.size() + " cpp files found by checkstyle"); // Create and run the command List<String> commandBuilder = new ArrayList<>(); commandBuilder.add(cpplintFile); commandBuilder.add("--linelength=100"); // TODO: https://github.com/twitter/heron/issues/466, // Remove "runtime/references" when we fix all non-const references in our codebase. // TODO: https://github.com/twitter/heron/issues/467, // Remove "runtime/threadsafe_fn" when we fix all non-threadsafe libc functions commandBuilder.add("--filter=-build/header_guard,-runtime/references,-runtime/threadsafe_fn"); commandBuilder.addAll(sourceFiles); runLinter(commandBuilder); } catch (ParseException exp) { LOG.severe(String.format("Invalid input to %s: %s", CLASSNAME, exp.getMessage())); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java " + CLASSNAME, options); } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { CertificateFactory cf = CertificateFactory.getInstance("X.509"); List mylist = new ArrayList(); FileInputStream in = new FileInputStream(args[0]); Certificate c = cf.generateCertificate(in); mylist.add(c); CertPath cp = cf.generateCertPath(mylist); FileInputStream kin = new FileInputStream(args[0]); KeyStore ks = KeyStore.getInstance("JKS"); ks.load(kin, args[1].toCharArray()); PKIXParameters params = new PKIXParameters(ks); params.setRevocationEnabled(false);/* w w w. ja v a 2s . c o m*/ CertPathValidator cpv = CertPathValidator.getInstance("PKIX"); PKIXCertPathValidatorResult result = (PKIXCertPathValidatorResult) cpv.validate(cp, params); PublicKey pbk = result.getPublicKey(); byte[] pkenc = pbk.getEncoded(); BigInteger pk = new BigInteger(pkenc); System.out.println(pk.toString(16)); TrustAnchor anc = result.getTrustAnchor(); X509Certificate xc = anc.getTrustedCert(); System.out.println(xc.getSubjectDN()); System.out.println(xc.getIssuerDN()); }
From source file:com.roquahacks.semafor4j.FrameNetService.java
public static void main(String[] args) { FrameNetService fnService;/*from ww w . j a va 2 s . c o m*/ fnService = new FrameNetService(FrameNetOptions.getStandardOpt("")); List<String> list = new ArrayList<String>(); list.add("The student sends his cv to the university"); list.add("Invite to aptitude test"); fnService.createAnnotationFile(list); }
From source file:edu.asu.ca.kaushik.algorithms.twostage.TwoStageSimple.java
public static void main(String[] args) throws IOException { int t = 0, k1 = 0, k2 = 0, v = 0, times = 0, f = 0, s = 0; if (args.length == 7) { t = Integer.parseInt(args[0]); v = Integer.parseInt(args[1]); k1 = Integer.parseInt(args[2]); k2 = Integer.parseInt(args[3]); times = Integer.parseInt(args[4]); f = Integer.parseInt(args[5]); s = Integer.parseInt(args[6]); } else {//www. j a va 2s . c o m System.err.println("Need seven arguments- t, v, kStart, kEnd, times, firstStage and slack percent"); System.exit(1); } List<CAGenAlgo> algoList = new ArrayList<CAGenAlgo>(); algoList.add(new TwoStageSimple(f, s)); System.out.println("times = " + times); OutputFormatter formatter = new TableOutputFormatter("data\\out\\tables\\two-stage", "two-stage-simple"); Runner runner = new Runner(formatter); runner.setParam(t, v, k1, k2); runner.setAlgos(algoList); runner.run(); /*TwoStage gts = new TwoStageSimple(0,0,0); System.out.println(gts.partialArraySize(6, 53, 3));*/ }
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 {//from w w w . ja v a 2 s. com 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:edu.asu.ca.kaushik.algorithms.permvector.MTPermutationVector.java
/** * @param args// w w w .j a v a 2s .c om * @throws IOException */ public static void main(String[] args) throws IOException { int t = 0, k1 = 0, k2 = 0, v = 0; if (args.length == 4) { t = Integer.parseInt(args[0]); v = Integer.parseInt(args[1]); k1 = Integer.parseInt(args[2]); k2 = Integer.parseInt(args[3]); } else { System.err.println("Need four arguments- t, v, kStart and kEnd"); System.exit(1); } List<CAGenAlgo> algoList = new ArrayList<CAGenAlgo>(); algoList.add(new MTPermutationVector()); OutputFormatter formatter = new TableOutputFormatter("data\\out\\tables\\perm-vec", "perm-vec"); Runner runner = new Runner(formatter); runner.setParam(t, v, k1, k2); runner.setAlgos(algoList); runner.run(); }
From source file:Main.java
public static void main(String[] args) { List<Integer> first = Arrays.asList(2, 3, 4, 5); List<Integer> second = Arrays.asList(1, 3, 4, 6); List<Integer> missing = new LinkedList<Integer>(); List<Integer> added = new LinkedList<Integer>(second); for (Integer i : first) { if (!added.remove(i)) { missing.add(i); }/*from w w w.ja v a 2s . co m*/ } System.out.println("Missing ints in second: " + missing); System.out.println("New ints in second: " + added); }
From source file:com.alibaba.jstorm.utils.NetWorkUtils.java
public static void main(String[] args) { List<String> servers = new ArrayList<String>(); servers.add("localhost"); System.out.println(host2Ip(servers)); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { CertificateFactory cf = CertificateFactory.getInstance("X.509"); List mylist = new ArrayList(); for (int i = 0; i < args.length; i++) { FileInputStream in = new FileInputStream(args[i]); Certificate c = cf.generateCertificate(in); mylist.add(c); }// ww w. j a v a 2 s . c o m CertPath cp = cf.generateCertPath(mylist); System.out.println(cp); }