Here you can find the source of getIterable(final Iterator
public static <T> Iterable<T> getIterable(final Iterator<T> i)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; public class Main { /**//w w w . j av a 2s. c o m * Wraps iterator into iterable */ public static <T> Iterable<T> getIterable(final Iterator<T> i) { return new Iterable<T>() { @Override public Iterator<T> iterator() { return i; } }; } }