public static < T > List < T > asList ( Iterator < T > itr ) { List < T > l = new ArrayList <> ( ) ; if ( itr != null ) { while ( itr . hasNext ( ) ) { l . add ( itr . next ( ) ) ; } } return l ; }
Returns an iterator as a list .