Interface IOIterator<E>

  • Type Parameters:
    E - the type of elements returned by this iterator.

    public interface IOIterator<E>
    Like Iterator but throws IOException.
    Since:
    2.12.0
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      static <E> IOIterator<E> adapt​(java.util.Iterator<E> iterator)
      Adapts the given Iterator as an IOIterator.
      default java.util.Iterator<E> asIterator()
      Creates an Iterator for this instance that throws UncheckedIOException instead of IOException.
      default void forEachRemaining​(IOConsumer<? super E> action)
      Like Iterator.forEachRemaining(Consumer).
      boolean hasNext()
      Like Iterator.hasNext().
      E next()
      Like Iterator.next().
      default void remove()
      Like Iterator.remove().
      java.util.Iterator<E> unwrap()
      Unwraps this instance and returns the underlying Iterator.
    • Method Detail

      • adapt

        static <E> IOIterator<E> adapt​(java.util.Iterator<E> iterator)
        Adapts the given Iterator as an IOIterator.
        Type Parameters:
        E - the type of the stream elements.
        Parameters:
        iterator - The iterator to adapt
        Returns:
        A new IOIterator
      • asIterator

        default java.util.Iterator<E> asIterator()
        Creates an Iterator for this instance that throws UncheckedIOException instead of IOException.
        Returns:
        an UncheckedIOException Iterator.
      • forEachRemaining

        default void forEachRemaining​(IOConsumer<? super E> action)
                               throws java.io.IOException
        Like Iterator.forEachRemaining(Consumer).
        Parameters:
        action - See delegate.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • hasNext

        boolean hasNext()
                 throws java.io.IOException
        Like Iterator.hasNext().
        Returns:
        See delegate.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • next

        E next()
        throws java.io.IOException
        Like Iterator.next().
        Returns:
        See delegate.
        Throws:
        java.io.IOException - if an I/O error occurs.
        java.util.NoSuchElementException - if the iteration has no more elements
      • remove

        default void remove()
                     throws java.io.IOException
        Like Iterator.remove().
        Throws:
        java.io.IOException - if an I/O error occurs.
      • unwrap

        java.util.Iterator<E> unwrap()
        Unwraps this instance and returns the underlying Iterator.

        Implementations may not have anything to unwrap and that behavior is undefined for now.

        Returns:
        the underlying Iterator.