Convert Iterator to Iterable

 
import java.util.Iterator;

public class Utils {
  public static <E> Iterable<E> iterable(final Iterator<E> iterator) {
      if (iterator == null) {
          throw new NullPointerException();
      }
      return new Iterable<E>() {
          public Iterator<E> iterator() {
              return iterator;
          }
      };
  }
}
  
Home 
  Java Book 
    Runnable examples  

Collection Iterator:
  1. Convert Iterator to Iterable
  2. Remove item with Iterator