commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Ring <...@jdns.org>
Subject Re: [io] File content iterator
Date Wed, 04 Jan 2006 21:33:04 GMT
Hi Stephen,

On Monday 02 January 2006 04:13, Stephen Colebourne wrote:
> See http://issues.apache.org/bugzilla/show_bug.cgi?id=38083
>
> The design for a line by line iterator over a file could potentially get
> much more interesting.
>
> The basic requirement is an iterator over Strings representing the file
> lines, that does not load the whole file in the background. This implies
> that the user is responsible for closing the iterator (although it could
> be done automatically once the hasNext() returns false).
>
> I was thinking of an class like this:
>
> public class OpenFileLineIterator implements Iterator {
>   boolean hasNext();
>   String nextLine();
>   void close();
> }
>
> Is this a reasonable design?

Looks fine to me.. Did you intend to use a BufferedReader for the 
implementation of nextLine()?

Also, maybe hasNext() will be a bit tricky to determine, because you don't 
know if you're at the end of a file until you try reading from it. Maybe this 
isn't a problem...

> Stephen

Regards,
James
-- 
James Ring

Mime
View raw message