commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 38083] - [io][PATCH] Iterate over the lines in a file and the files in a directory
Date Fri, 06 Jan 2006 00:03:41 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38083>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38083


niallp@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |WORKSFORME




------- Additional Comments From niallp@apache.org  2006-01-06 01:03 -------
(In reply to comment #9)
> I think the IOIterator is a good idea. There is an interface "Closeable" Java
> 1.5 which is used for the same purpose.
> >  IOIterator i = FileUtils.lineIterator( blah );
> Sorry to be pedantic, but ...
> Why declare i as an IOIterator when you can declare it as a LineIterator? 

IMO its better to keep the API to types rather than fixing on implementations - 
that way, if a better implementation comes along at a later date then the 
public API doesn't have to change at a to take advantage of it.

> I want to 
> iterate over Lines, not over IOs... But, anyway, the point is that if you
> return LineIterator, you give the user the choice. We don't gain anything by
> returning a superinterface in this case.

You don't gain anything by returning a LineIterator - it has the same methods 
(i.e. Iterator methods plus a close() method) as IOIterator - I created it with 
that name as I was thinking there would be more flavours - Stephen talked about 
a couple and I like the idea of a BufferedInputIterator that returns byte[].

> > The other thing I wondered was maybe its better to have a new 
RuntimeException 
> > that includes the "cause" (I assume io is JDK 1.3 dependant, and not 1.4) 
> > rather than trapping IOException and re-throwing IllegalStateException with 
> > just the message.
> I don't think hasNext() should throw any exceptions. If you cannot read the 
file
> anymore, then there are no more elements. People using the Iterator interface
> will not expect hasNext() to throw an exception. Just close the reader as you
> have done.

I don't really like the idea of swallowing exceptions and carrying on as though 
everything is fine - sounds like a PITA to debug.

> Also, next() should throw a NoSuchElementException, rather than 
> IllegalStateException, according to the Iterator javadoc.

OK I'll change this, thx.

> > Niall
> Regards,
> James



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message