org.apache.commons.io.function

## 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 and Description
    --- | ---
    `static <E> IOIterator<E>` | `adapt(Iterator<E> iterator)` Adapts the given Iterator as an IOIterator.
    `default 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()`.
    `Iterator<E>` | `unwrap()` Unwraps this instance and returns the underlying `Iterator`.

- - ### Method Detail

    - #### adapt

          static <E> IOIterator<E> adapt(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 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 IOException

      Like `Iterator.forEachRemaining(Consumer)`.
      Parameters:
        `action` - See delegate.
      Throws:
        `IOException` - if an I/O error occurs.

    - #### hasNext

          boolean hasNext()
                   throws IOException

      Like `Iterator.hasNext()`.
      Returns:
        See delegate.
      Throws:
        `IOException` - if an I/O error occurs.

    - #### next

          E next()
          throws IOException

      Like `Iterator.next()`.
      Returns:
        See delegate.
      Throws:
        `IOException` - if an I/O error occurs.
        `NoSuchElementException` - if the iteration has no more elements

    - #### remove

          default void remove()
                       throws IOException

      Like `Iterator.remove()`.
      Throws:
        `IOException` - if an I/O error occurs.

    - #### unwrap

          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.

Copyright © 2002–2023 The Apache Software Foundation. All rights reserved.