public static < T > List < T > collect ( Iterator < T > iterator ) { List < T > list = new ArrayList < T > ( ) ; while ( iterator . hasNext ( ) ) { list . add ( iterator . next ( ) ) ; } return list ; }
Collect an iterator s elements into a List .