1 6 7 package com.hp.hpl.jena.util; 8 9 import java.util.ArrayList ; 10 import java.util.Iterator ; 11 import java.util.List ; 12 import java.util.Set ; 13 14 import com.hp.hpl.jena.util.iterator.NiceIterator; 15 16 17 20 public class IteratorCollection 21 { 22 25 private IteratorCollection() 26 {} 27 28 34 public static Set iteratorToSet( Iterator i ) 35 { 36 Set result = CollectionFactory.createHashedSet(); 37 try { while (i.hasNext()) result.add( i.next() ); } 38 finally { NiceIterator.close( i ); } 39 return result; 40 } 41 42 49 public static List iteratorToList( Iterator it ) 50 { 51 List result = new ArrayList (); 52 try { while (it.hasNext()) result.add( it.next() ); } 53 finally { NiceIterator.close( it ); } 54 return result; 55 } 56 57 } 58 59 60 | Popular Tags |