public interface CloseableIteration<E,X extends Exception> extends Iteration<E,X>, AutoCloseable
Iteration
that can be closed to free resources that it is holding. CloseableIterations automatically free
their resources when exhausted. If not read until exhaustion or if you want to make sure the iteration is properly
closed, any code using the iterator should be placed in a try-with-resources block, closing the iteration
automatically, e.g.:
try (CloseableIteration<Object, Exception> iter = ...) { // read objects from the iterator } catch(Exception e) { // process the exception that can be thrown while processing. }
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this iteration, freeing any resources that it is holding.
|
Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.