Interface CloseableIterator<T,​TEx extends java.lang.Exception>

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface CloseableIterator<T,​TEx extends java.lang.Exception>
    extends java.lang.AutoCloseable
    Defines an Iterator that can be closed. This can be used for such iterators that need to acquire or make use of expensive system resources, such as network connections or file handles. Closing the iterator will release all such resources, even if getNext() indicates that it hasn't reached the end.
    • Method Detail

      • getNext

        T getNext()
           throws TEx extends java.lang.Exception
        Gets the next item in the iteration.
        Returns:
        The next item, or null if no more elements.
        Throws:
        ObjectClosedException - If the CloseableIterator has been closed.
        TEx - If an exception of this type occurred.
        TEx extends java.lang.Exception
      • close

        void close()
        Closes the Iterator.
        Specified by:
        close in interface java.lang.AutoCloseable