Package org.apache.commons.io
Class StreamIterator<E>
- java.lang.Object
 - 
- org.apache.commons.io.StreamIterator<E>
 
 
- 
- Type Parameters:
 E- TheStreamandIteratortype.
- All Implemented Interfaces:
 java.lang.AutoCloseable,java.util.Iterator<E>
public final class StreamIterator<E> extends java.lang.Object implements java.util.Iterator<E>, java.lang.AutoCloseableWraps and presents aStreamas aAutoCloseableIteratorresource that automatically closes itself when reaching the end of stream.Warning
In order to close the stream, the call site MUST either close the stream it allocated OR call this iterator until the end.
- Since:
 - 2.15.0
 
 
- 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the underlying stream.booleanhasNext()static <T> StreamIterator<T>iterator(java.util.stream.Stream<T> stream)Wraps and presents a stream as a closable resource that automatically closes itself when reaching the end of stream.Enext() 
 - 
 
- 
- 
Method Detail
- 
iterator
public static <T> StreamIterator<T> iterator(java.util.stream.Stream<T> stream)
Wraps and presents a stream as a closable resource that automatically closes itself when reaching the end of stream.Warning
In order to close the stream, the call site MUST either close the stream it allocated OR call this iterator until the end.
- Type Parameters:
 T- The stream and iterator type.- Parameters:
 stream- The stream iterate.- Returns:
 - A new iterator.
 
 
- 
close
public void close()
Closes the underlying stream.- Specified by:
 closein interfacejava.lang.AutoCloseable
 
- 
hasNext
public boolean hasNext()
- Specified by:
 hasNextin interfacejava.util.Iterator<E>
 
 - 
 
 -