info.aduna.collections.iterators
Interface CloseableIterator<E>

All Superinterfaces:
Closeable, Iterator<E>
All Known Implementing Classes:
ConvertingIterator, DelayedIterator, DistinctIterator, EmptyIterator, FilterIterator, IntersectIterator, IteratorWrapper, LimitIterator, LockingIterator, LookAheadIterator, MinusIterator, OffsetIterator, SingletonIterator, UnionIterator

public interface CloseableIterator<E>
extends Iterator<E>, Closeable

An iterator that can be closed to free resources that it is holding. CloseableIterators are automatically closed when exhausted. If not read until exhaustion or if you want to make sure the iterator is properly closed, any code using the iterator should be placed in a try-finally block, closing the iterator in the finally, e.g.:

 CloseableIterator<Object> iter = ...
 try {
    // read objects from the iterator
 }
 finally {
    iter.close();
 }
 


Method Summary
 void close()
          Closes this iterator, freeing any resources that it is holding.
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Method Detail

close

void close()
Closes this iterator, freeing any resources that it is holding. If the iterator is already closed then invoking this method has no effect.

Specified by:
close in interface Closeable


Copyright © 1997-2008 Aduna. All Rights Reserved.