java.lang.Object
net.i2p.addressbook.HostTxtIterator
- All Implemented Interfaces:
Closeable, AutoCloseable, Iterator<Map.Entry<String, HostTxtEntry>>
A class to iterate through a hosts.txt or config file without reading the whole thing into memory. Keys are always converted to lower case.
Callers should iterate all the way through or call close() to ensure the underlying stream is closed.
This is not used for config files. It is only used for subscriptions.
Constructor Summary
ConstructorsConstructorDescriptionA dummy iterator in which hasNext() is always false.HostTxtIterator(File file) An iterator over the key/value pairs in the file.Method Summary
All MethodsMethods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterator
forEachRemaining
Constructor Details
HostTxtIterator
public HostTxtIterator()A dummy iterator in which hasNext() is always false.HostTxtIterator
An iterator over the key/value pairs in the file.- Parameters:
file- the hosts.txt or subscription file to read, opened as UTF-8- Throws:
IOException- if the file cannot be opened or read
Method Details
hasNext
public boolean hasNext()Return true if there is another entry to return.- Specified by:
hasNextin interfaceIterator<Map.Entry<String, HostTxtEntry>>- Returns:
- true if there is another entry
next
Return the next entry. 'remove' entries will be returned with a null key, and the value will contain a null name, null dest, and non-null props.- Specified by:
nextin interfaceIterator<Map.Entry<String, HostTxtEntry>>- Returns:
- the next entry
- Throws:
NoSuchElementException- if there is no next entry
remove
public void remove()Not supported.- Specified by:
removein interfaceIterator<Map.Entry<String, HostTxtEntry>>- Throws:
UnsupportedOperationException- always; this iterator cannot remove
close
public void close()Close the underlying stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable