Java Iterator closeIterator(Iterator iterator)

Here you can find the source of closeIterator(Iterator iterator)

Description

Closes an iterator if it has interface ClosableIterator.

License

Open Source License

Declaration

public static void closeIterator(Iterator<?> iterator) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Iterator;

public class Main {
    /**/*from  w  w w  .j  a v a2  s.  c  om*/
     * Closes an iterator if it has interface ClosableIterator. This is useful
     * to avoid open iterator warnings when we're not interested in all results
     * of a sparql query.
     */
    public static void closeIterator(Iterator<?> iterator) {
        while (iterator.hasNext()) {
            iterator.next();
        }
    }
}

Related

  1. asArray(T[] arr, Iterator itr)
  2. asList(final Iterator iterator)
  3. asList(Iterator it)
  4. asStringOn(StringBuffer sb, Iterator iter, String separator)
  5. cast(Iterator p)
  6. compareRanges(final Iterator i, final Iterator j)
  7. concatinateElements(Iterator it)
  8. concatIterators(final Iterator... iterators)
  9. concatLines(Iterator lineIterator)