Lazy sequences do not interact well with resources that need to be closed. 
This is a long-standing issue, and no universal solution has been found.

The usual recommendation is to manage the resource in a higher scope than 
the process that uses it. In your case, rather than creating the iterator 
and seq in the same function, create the iterator higher up the call stack 
where it can be managed by 'with-open' or an equivalent. Then create the 
lazy seq where you need it.

As to why iterator-seq doesn't work, your code appears to be using an 
Iterator interface (peekNext) which is different from Java's standard 
iterator:
http://docs.oracle.com/javase/6/docs/api/java/util/Iterator.html

-S

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to