List of usage examples for java.util Iterator next
E next();
From source file:Main.java
public static void main(String[] args) throws Exception { SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance(); SOAPConnection connection = sfc.createConnection(); MessageFactory mf = MessageFactory.newInstance(); SOAPMessage sm = mf.createMessage(); QName bodyName = new QName("http://YourSOAPServer.com", "GetQuote", "d"); URL endpoint = new URL("http://YourSOAPServer.com"); SOAPMessage response = connection.call(sm, endpoint); SOAPBody sb = response.getSOAPBody(); java.util.Iterator iterator = sb.getChildElements(bodyName); while (iterator.hasNext()) { SOAPBodyElement bodyElement = (SOAPBodyElement) iterator.next(); String val = bodyElement.getValue(); System.out.println("The Value is:" + val); }/*from w ww . j a v a 2 s . c o m*/ }
From source file:TimeTrial.java
public static void main(String[] args) { StopWatch stWatch = new StopWatch(); // Start StopWatch stWatch.start();//from ww w . j av a 2 s.c o m // Get iterator for all days in a week starting Monday Iterator itr = DateUtils.iterator(new Date(), DateUtils.RANGE_WEEK_MONDAY); while (itr.hasNext()) { Calendar gCal = (Calendar) itr.next(); System.out.println(gCal.getTime()); } // Stop StopWatch stWatch.stop(); System.out.println("Time Taken >>" + stWatch.getTime()); }
From source file:Main.java
public static void main(String[] args) { String html = "<!html>" + "<html><body>" + "<span id='my'>" + "<span class=''contentTitle'>Director:</span>" + "<span>test</span></span>" + "</body></html>"; Document doc = Jsoup.parse(html); System.out.println(doc.toString()); Elements spanWithId = doc.select("span#my"); if (spanWithId != null) { System.out.printf("Found %d Elements\n", spanWithId.size()); if (!spanWithId.isEmpty()) { Iterator<Element> it = spanWithId.iterator(); Element element = null; while (it.hasNext()) { element = it.next(); System.out.println(element.toString()); }/*from w ww . j av a 2 s. c o m*/ } } }
From source file:Main.java
public static void main(String[] argv) throws Exception { Selector selector = Selector.open(); ServerSocketChannel ssChannel1 = ServerSocketChannel.open(); ssChannel1.configureBlocking(false); ssChannel1.socket().bind(new InetSocketAddress(80)); ServerSocketChannel ssChannel2 = ServerSocketChannel.open(); ssChannel2.configureBlocking(false); ssChannel2.socket().bind(new InetSocketAddress(81)); ssChannel1.register(selector, SelectionKey.OP_ACCEPT); ssChannel2.register(selector, SelectionKey.OP_ACCEPT); while (true) { selector.select();//from w w w .ja va2 s. c o m Iterator it = selector.selectedKeys().iterator(); while (it.hasNext()) { SelectionKey selKey = (SelectionKey) it.next(); it.remove(); if (selKey.isAcceptable()) { ServerSocketChannel ssChannel = (ServerSocketChannel) selKey.channel(); SocketChannel sc = ssChannel.accept(); ByteBuffer bb = ByteBuffer.allocate(100); sc.read(bb); } } } }
From source file:cat.tv3.eng.rec.recomana.lupa.visualization.RecommendationToJson.java
public static void main(String[] args) throws IOException { final int TOTAL_WORDS = 20; String host = args[0];/*from w ww. jav a 2 s.c o m*/ int port = Integer.parseInt(args[1]); Jedis jedis = new Jedis(host, port, 20000); String[] recommendation_keys = jedis.keys("recommendations_*").toArray(new String[0]); for (int i = 0; i < recommendation_keys.length; ++i) { JSONArray recommendations = new JSONArray(); String[] split_reco_name = recommendation_keys[i].split("_"); String id = split_reco_name[split_reco_name.length - 1]; Set<Tuple> recos = jedis.zrangeWithScores(recommendation_keys[i], 0, -1); Iterator<Tuple> it = recos.iterator(); while (it.hasNext()) { Tuple t = it.next(); JSONObject new_reco = new JSONObject(); new_reco.put("id", t.getElement()); new_reco.put("distance", (double) Math.round(t.getScore() * 10000) / 10000); recommendations.add(new_reco); } saveResults(recommendations, id); } jedis.disconnect(); }
From source file:com.discursive.jccook.xml.bardsearch.TermFreq.java
public static void main(String[] pArgs) throws Exception { logger.info("Threshold is 200"); Integer threshold = new Integer(200); IndexReader reader = IndexReader.open("index"); TermEnum enumVar = reader.terms();// w w w . j ava2 s . c om List termList = new ArrayList(); while (enumVar.next()) { if (enumVar.docFreq() >= threshold.intValue() && enumVar.term().field().equals("speech")) { Freq freq = new Freq(enumVar.term().text(), enumVar.docFreq()); termList.add(freq); } } Collections.sort(termList); Collections.reverse(termList); System.out.println("Frequency | Term"); Iterator iterator = termList.iterator(); while (iterator.hasNext()) { Freq freq = (Freq) iterator.next(); System.out.print(freq.frequency); System.out.println(" | " + freq.term); } }
From source file:XMLEventReaderDemo.java
public static void main(String[] args) throws Exception { XMLInputFactory factory = XMLInputFactory.newInstance(); Reader fileReader = new FileReader("Source.xml"); XMLEventReader reader = factory.createXMLEventReader(fileReader); while (reader.hasNext()) { XMLEvent event = reader.nextEvent(); if (event.isStartElement()) { StartElement element = (StartElement) event; System.out.println("Start Element: " + element.getName()); Iterator iterator = element.getAttributes(); while (iterator.hasNext()) { Attribute attribute = (Attribute) iterator.next(); QName name = attribute.getName(); String value = attribute.getValue(); System.out.println("Attribute name/value: " + name + "/" + value); }/*from w ww . j av a 2 s . c o m*/ } if (event.isEndElement()) { EndElement element = (EndElement) event; System.out.println("End element:" + element.getName()); } if (event.isCharacters()) { Characters characters = (Characters) event; System.out.println("Text: " + characters.getData()); } } }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> list = new ArrayList<String>(); list.add("Monday"); list.add("Tuesdag"); list.add("Wednesday"); list.add("Thursday"); list.add("Friday"); list.add("Saturday"); list.add("Sunday"); Iterator<String> iterator = null; iterator = list.iterator();/*from www .j ava 2s . com*/ while (iterator.hasNext()) { String element = iterator.next(); System.out.println(element); } for (iterator = list.iterator(); iterator.hasNext();) { String element = iterator.next(); System.out.println(element); } for (String element : list) { System.out.println(element); } }
From source file:MainClass.java
public static void main(String[] args) throws IOException { for (int i = 0; i < data.length; i++) data[i] = (byte) i; ServerSocketChannel server = ServerSocketChannel.open(); server.configureBlocking(false);/*from w ww . j av a2s .c o m*/ server.socket().bind(new InetSocketAddress(9000)); Selector selector = Selector.open(); server.register(selector, SelectionKey.OP_ACCEPT); while (true) { selector.select(); Set readyKeys = selector.selectedKeys(); Iterator iterator = readyKeys.iterator(); while (iterator.hasNext()) { SelectionKey key = (SelectionKey) iterator.next(); iterator.remove(); if (key.isAcceptable()) { SocketChannel client = server.accept(); System.out.println("Accepted connection from " + client); client.configureBlocking(false); ByteBuffer source = ByteBuffer.wrap(data); SelectionKey key2 = client.register(selector, SelectionKey.OP_WRITE); key2.attach(source); } else if (key.isWritable()) { SocketChannel client = (SocketChannel) key.channel(); ByteBuffer output = (ByteBuffer) key.attachment(); if (!output.hasRemaining()) { output.rewind(); } client.write(output); } key.channel().close(); } } }
From source file:SOAPResponse.java
public static void main(String[] args) { try {/*from ww w . ja v a 2 s . c o m*/ SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance(); SOAPConnection connection = sfc.createConnection(); MessageFactory mf = MessageFactory.newInstance(); SOAPMessage sm = mf.createMessage(); QName bodyName = new QName("http://YourSOAPServer.com", "GetQuote", "d"); URL endpoint = new URL("http://YourSOAPServer.com"); SOAPMessage response = connection.call(sm, endpoint); SOAPBody sb = response.getSOAPBody(); java.util.Iterator iterator = sb.getChildElements(bodyName); while (iterator.hasNext()) { SOAPBodyElement bodyElement = (SOAPBodyElement) iterator.next(); String val = bodyElement.getValue(); System.out.println("The Value is:" + val); } } catch (Exception ex) { ex.printStackTrace(); } }