Here you can find the source of count(final Iterator iterator)
public static final long count(final Iterator iterator)
//package com.java2s; //License from project: Apache License import java.util.Iterator; public class Main { public static final long count(final Iterator iterator) { long ix = 0; for (; iterator.hasNext(); ++ix) iterator.next();//from ww w.j a va 2s . c o m return ix; } }