Search code examples
javaguavaapache-commons

Way to convert Iterator to mutable List in Java using `apache-commons`, `guava` or some other popular library


Is there any magicMethod working like this:

List<E> resultList = magicMethod((Iterator<E>)inputIterator);

NB: resultList should be mutable.


Solution

  • You can use Lists#newArrayList(Iterator).