org.apache.crunch.io.impl
Class AutoClosingIterator<T>
java.lang.Object
com.google.common.collect.UnmodifiableIterator<T>
org.apache.crunch.io.impl.AutoClosingIterator<T>
- All Implemented Interfaces:
- Closeable, Iterator<T>
public class AutoClosingIterator<T>
- extends com.google.common.collect.UnmodifiableIterator<T>
- implements Closeable
Closes the wrapped Closeable
when hasNext()
returns false. As long a client loops through to
completion (doesn't abort early due to an exception, short circuit, etc.) resources will be closed automatically.
Methods inherited from class com.google.common.collect.UnmodifiableIterator |
remove |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AutoClosingIterator
public AutoClosingIterator(Closeable closeable,
Iterator<T> iter)
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interface Iterator<T>
next
public T next()
- Specified by:
next
in interface Iterator<T>
close
public void close()
throws IOException
- Specified by:
close
in interface Closeable
- Throws:
IOException
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.