List of usage examples for java.util Iterator next
E next();
From source file:LegacyTest.java
public static void main(String[] args) { try {//w w w.j a va 2 s.c o m PdfAs pdfAS = PdfAsFactory.createPdfAs(); SignParameters signParameters = new SignParameters(); signParameters.setSignatureDevice("bku"); signParameters.setSignatureProfileId("SIGNATURBLOCK_DE"); InputStream is = LegacyTest.class.getResourceAsStream("simple.pdf"); byte[] inputData = IOUtils.toByteArray(is); ByteArrayDataSink bads = new ByteArrayDataSink(); signParameters.setDocument(new ByteArrayDataSource(inputData)); signParameters.setOutput(bads); SignResult result = pdfAS.sign(signParameters); IOUtils.write(bads.getBytes(), new FileOutputStream("/tmp/test.pdf")); System.out.println("Signed @ " + result.getSignaturePosition().toString()); System.out.println("Signed by " + result.getSignerCertificate().getSubjectDN().getName()); VerifyParameters verifyParameters = new VerifyParameters(); verifyParameters.setDocument(new ByteArrayDataSource(bads.getBytes())); verifyParameters.setSignatureToVerify(0); VerifyResults results = pdfAS.verify(verifyParameters); Iterator iter = results.getResults().iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj instanceof VerifyResult) { VerifyResult vresult = (VerifyResult) obj; System.out.println("Verified: " + vresult.getValueCheckCode().getCode() + " " + vresult.getValueCheckCode().getMessage()); } } } catch (Throwable e) { System.out.println("ERROR"); e.printStackTrace(); } }
From source file:CAList.java
/** * <p><!-- Method description --></p> * * * @param args/* ww w .ja v a2s . c om*/ */ public static void main(String[] args) { try { // Load the JDK's cacerts keystore file String filename = System.getProperty("java.home") + "/lib/security/cacerts".replace('/', File.separatorChar); FileInputStream is = new FileInputStream(filename); KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); String password = "changeit"; keystore.load(is, password.toCharArray()); // This class retrieves the most-trusted CAs from the keystore PKIXParameters params = new PKIXParameters(keystore); // Get the set of trust anchors, which contain the most-trusted CA certificates Iterator it = params.getTrustAnchors().iterator(); for (; it.hasNext();) { TrustAnchor ta = (TrustAnchor) it.next(); // Get certificate X509Certificate cert = ta.getTrustedCert(); System.out.println("<issuer>" + cert.getIssuerDN() + "</issuer>\n"); } } catch (CertificateException e) { } catch (KeyStoreException e) { } catch (NoSuchAlgorithmException e) { } catch (InvalidAlgorithmParameterException e) { } catch (IOException e) { } }
From source file:is.java
public static void main(String[] args) { List<Integer> list = Arrays.asList(3, 2, 4, 1, 5); NavigableSet<Integer> ns = new TreeSet<Integer>(list); System.out.println("Ascending order (default): " + ns); Iterator<Integer> descendingIterator = ns.descendingIterator(); StringBuilder sb = new StringBuilder("Descending order: "); while (descendingIterator.hasNext()) { int m = descendingIterator.next(); sb.append(m + " "); }//from w w w . jav a2 s.co m System.out.println(sb); int greatest = ns.lower(3); System.out.println("Lower of 3 = " + greatest); int smallest = ns.higher(3); System.out.println("Higher of 3 = " + smallest); }
From source file:ImageTest.java
public static void main(String args[]) { args = new String[] { "image.json" }; for (int a = 0; a < args.length; a++) { String version = "Unknown"; try {//from w ww . j av a2s .c om JSONTokener tokener = new JSONTokener(new FileInputStream(args[a])); JSONObject jsonSubject = new JSONObject(tokener); JSONObject jsonSchema = new JSONObject( new JSONTokener(ImageTest.class.getResourceAsStream("schema.json"))); Schema schema = SchemaLoader.load(jsonSchema); schema.validate(jsonSubject); System.out.println("json-schema Valid " + args[a]); } catch (NullPointerException e) { System.out.println("json-config null point error " + args[a]); } catch (FileNotFoundException e) { System.out.println("json-file file missing " + e.getMessage() + " " + args[a]); } catch (JSONException je) { System.out.println("json-parse json " + je.getMessage() + " " + args[a]); } catch (ValidationException ve) { Iterator<ValidationException> i = ve.getCausingExceptions().iterator(); while (i.hasNext()) { ValidationException veel = i.next(); System.out.println("json-schema Validation error " + veel + " " + args[a]); } } } }
From source file:NavigableSetDemo.java
public static void main(String[] args) { List<Integer> list = Arrays.asList(3, 2, 4, 1, 5); NavigableSet<Integer> ns = new TreeSet<Integer>(list); System.out.println("Ascending order (default): " + ns); Iterator<Integer> descendingIterator = ns.descendingIterator(); StringBuilder sb = new StringBuilder("Descending order: "); while (descendingIterator.hasNext()) { int m = descendingIterator.next(); sb.append(m + " "); }/*from w w w . j a v a2s . c o m*/ System.out.println(sb); int greatest = ns.lower(3); System.out.println("Lower of 3 = " + greatest); int smallest = ns.higher(3); System.out.println("Higher of 3 = " + smallest); }
From source file:au.org.ands.vocabs.toolkit.db.DumpAccessPointsData.java
/** * Main program./*from ww w . j a va 2 s. co m*/ * @param args Command-line arguments */ public static void main(final String[] args) { List<AccessPoint> aps = AccessPointUtils.getAllAccessPoints(); for (AccessPoint ap : aps) { System.out.println(ap.getId()); System.out.println(ap.getVersionId()); System.out.println(ap.getType()); String pd = ap.getPortalData(); String td = ap.getToolkitData(); System.out.println("portal_data:"); JsonNode pdJson = TaskUtils.jsonStringToTree(pd); Iterator<Entry<String, JsonNode>> pdJsonIterator = pdJson.fields(); while (pdJsonIterator.hasNext()) { Entry<String, JsonNode> entry = pdJsonIterator.next(); System.out.println(entry.getKey() + "=" + entry.getValue().asText()); } System.out.println("toolkit_data:"); JsonNode tdJson = TaskUtils.jsonStringToTree(td); Iterator<Entry<String, JsonNode>> tdJsonIterator = tdJson.fields(); while (tdJsonIterator.hasNext()) { Entry<String, JsonNode> entry = tdJsonIterator.next(); System.out.println(entry.getKey() + "=" + entry.getValue().asText()); } } }
From source file:ObjectTest.java
public static void main(String args[]) { for (int a = 0; a < args.length; a++) { String version = "Unknown"; try {// w ww .ja v a2 s. c o m JSONTokener tokener = new JSONTokener(new FileInputStream(args[a])); JSONObject jsonSubject = new JSONObject(tokener); version = jsonSubject.getJSONObject("X3D").getString("@version"); JSONObject jsonSchema = new JSONObject(new JSONTokener( ObjectTest.class.getResourceAsStream("x3d-" + version + "-JSONSchema.json"))); Schema schema = SchemaLoader.load(jsonSchema); schema.validate(jsonSubject); // System.out.println("json-schema "+version+" Valid "+args[a]); } catch (NullPointerException npe) { System.out.println("json-config " + version + " null point error " + args[a]); } catch (FileNotFoundException e) { System.out.println("json-file file missing " + e.getMessage() + " " + args[a]); } catch (NumberFormatException nfe) { System.out.println("json-parse json " + nfe.getMessage() + " " + args[a]); } catch (JSONException je) { System.out.println("json-parse json " + je.getMessage() + " " + args[a]); } catch (ValidationException ve) { Iterator<ValidationException> i = ve.getCausingExceptions().iterator(); while (i.hasNext()) { ValidationException veel = i.next(); System.out.println("json-schema " + version + " Validation error " + veel + " " + args[a]); } } } }
From source file:com.apipulse.bastion.Main.java
public static void main(String[] args) throws IOException, ClassNotFoundException { log.info("Bastion starting. Loading chains"); final File dir = new File("etc/chains"); final LinkedList<ActorRef> chains = new LinkedList<ActorRef>(); for (File file : dir.listFiles()) { if (!file.getName().startsWith(".") && file.getName().endsWith(".yaml")) { log.info("Loading chain: " + file.getName()); ChainConfig config = new ChainConfig(IOUtils.toString(new FileReader(file))); ActorRef ref = BastionActors.getInstance().initChain(config.getName(), Class.forName(config.getQualifiedClass())); Iterator<StageConfig> iterator = config.getStages().iterator(); while (iterator.hasNext()) ref.tell(iterator.next(), null); chains.add(ref);// ww w. j av a2 s. co m } } SpringApplication app = new SpringApplication(); HashSet<Object> objects = new HashSet<Object>(); objects.add(ApiController.class); final ConfigurableApplicationContext context = app.run(ApiController.class, args); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { log.info("Bastion shutting down"); Iterator<ActorRef> iterator = chains.iterator(); while (iterator.hasNext()) iterator.next().tell(new StopMessage(), null); Thread.sleep(2000); context.stop(); log.info("Bastion shutdown complete"); } catch (Exception e) { } } }); }
From source file:Main.java
public static void main(String[] args) { // Create a list of strings List<String> names = new ArrayList<>(); names.add("A"); names.add("B"); names.add("C"); // Get an iterator for the list Iterator<String> nameIterator = names.iterator(); // Iterate over all elements in the list while (nameIterator.hasNext()) { // Get the next element from the list String name = nameIterator.next(); System.out.println(name); }/*from ww w . j a va2 s.com*/ }
From source file:Main.java
public static void main(String[] args) { // Create a list of strings List<String> names = new ArrayList<>(); names.add("A"); names.add("B"); names.add("C"); Iterator<String> nameIterator = names.iterator(); // Iterate over all elements in the list while (nameIterator.hasNext()) { // Get the next element from the list String name = nameIterator.next(); System.out.println(name); nameIterator.remove();/*ww w . j a v a 2 s . c om*/ } System.out.println(names); }