Java tutorial
//package com.java2s; import java.util.Iterator; public class Main { public static <E> Iterable<E> asIterable(final Iterator<E> i) { return new Iterable<E>() { @Override public Iterator<E> iterator() { return i; } }; } }