guava/src/com/google/common/collect/Iterables.java
public static <T> Iterable<T> limit(final Iterable<T> iterable, final int limitSize) {
    checkNotNull(iterable);
    checkArgument(limitSize >= 0, "limit is negative");
    return new FluentIterable<T>() {
      @Override
      public Iterator<T> iterator() {
        return Iterators.limit(iterable.iterator(), limitSize);
      }

      @Override
      public Spliterator<T> spliterator() {
        return Streams.stream(iterable).limit(limitSize).spliterator();
      }
    };
  }
public static <T> Iterable<T> limit(final Iterable<T> iterable, final int limitSize) {
    checkNotNull(iterable);
    checkArgument(limitSize >= 0, "limit is negative");
    return new FluentIterable<T>() {
      @Override
      public Iterator<T> iterator() {
        return Iterators.limit(iterable.iterator(), limitSize);
      }

      @Override
      public Spliterator<T> spliterator() {
        return Streams.stream(iterable).limit(limitSize).spliterator();
      }
    };
  }
Returns a view of {@code iterable} containing its first {@code limitSize} elements. If {@code
iterable} contains fewer than {@code limitSize} elements, the returned view contains all of its
elements. The returned iterable's iterator supports {@code remove()} if {@code iterable}'s
iterator does.

<p><b>{@code Stream} equivalent:</b> {@link Stream#limit}

@param iterable the iterable to limit
@param limitSize the maximum number of elements in the returned iterable
@throws IllegalArgumentException if {@code limitSize} is negative
@since 3.0