commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <niall.pember...@gmail.com>
Subject Re: TextIterable ?
Date Sat, 27 Oct 2007 03:17:38 GMT
On 10/26/07, Hanson Char <hanson.char@gmail.com> wrote:
> BTW, there already exists a public standalone class LineIterator:
>
>   http://commons.apache.org/io/apidocs/org/apache/commons/io/LineIterator.html
>
> Same name but for different uses/intents :)

I don't get this - same name, same uses/intents from my PoV.

I also don't really see the value of TextIterable on top of
LineIterator. Seems to me to be lumping two different steps into one
convenience class ---> 1) Creating a file Reader and 2) iterating over
a reader. Also we have a convenience static method in FileUtils that
does do that: http://tinyurl.com/3cesoo - so the following code does
pretty much the main job of TextIterable:

 LineIterator it = FileUtils.lineIterator(file, "UTF-8");
 try {
   while (it.hasNext()) {
     String line = it.nextLine();
     /// do something with line
   }
 } finally {
   LineIterator.closeQuietly(iterator);
 }

Niall

> Hanson Char
>
> On 10/25/07, Hanson Char <hanson.char@gmail.com> wrote:
> > Henri,
> >
> > LineIterator is intended/designed to be a hidden implementation behind
> > TextIterable.  It's like putting the cart in front of the horse.
> > Things don't make much sense if LineIterator is taken out of context
> > as a standalone public class - issues of InputStream vs Reader,
> > encoding, closing of input stream, etc. go away at the higher level of
> > abstraction, aka TextIterable.
> >
> > The 1.5 issue is, unfortunate, a real issue.  I haven't programmed in
> > pre-1.5 Java for 2+ years now.  Sorry for the folks who are not so
> > lucky.
> >
> > Hanson Char
> >
> >
> > On 10/25/07, Henri Yandell <flamefew@gmail.com> wrote:
> > > On 10/25/07, Hanson Char <hanson.char@gmail.com> wrote:
> > > > Would anyone be interested in including the proposed TextIterable in
> > > > the commons lang or commons io library ?
> > > >
> > > >   http://hansonchar.blogspot.com/2007/10/textiterable.html
> > >
> > > Things that jump out:
> > >
> > > * Definitely more IO than Lang.
> > > * 1.5 specific - Lang has a scratchspace for 1.5, IO currently doesn't
> > > have any 1.5 plans.
> > > * Needs to support encodings.
> > > * I'd prefer to be able to use LineIterator directly, and to have a
> > > Reader API in addition to the InputStream one.
> > > * I don't like that LineIterator closes the passed in InputStream.
> > >
> > > My suggestion - a JIRA issue for Commons IO for when it starts
> > > thinking about a 1.5 dependent version. The 1.5 requiring issues need
> > > to exist to build up a critical momentum.
> > >
> > > Hen
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

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


Mime
View raw message