Both
next
and previous
move the cursor after having accessed the file. There's not much you can do about it, unless you create a custom iterator. It would probably be better to use an ArrayList
and its get
method with an index you control, if possible.