Try this :
for (Iterator iter = reader.getFieldNames(FieldOption.ALL).iterator();
iter.hasNext();) {
String fieldName = (String)iter.next();
}
Your code creates iterator each time when you call next()
Also, if your method out.print() gets String as parameter, casting is
redundant
Regards
On Wed, Mar 19, 2008 at 6:26 PM, varun sood <[EMAIL PROTECTED]> wrote:
> Hi Shai,
> The code I pasted is not working.. sorry abt that..
> The code which is working is ..
>
> Collection c = ir.getFieldNames(IndexReader.FieldOption.ALL);
> int i = 0;
> while (c.iterator().hasNext()) {
> out.print(c.iterator().next(););
> i++;
> }
>
> This hangs my machine for minutes minutes on my dual core to optuput
> the result.
> I am doing sth wrong.
> "I mean I do not know where the field names are stored.. " in the enum
> and how to get them.
> Perhaps its a trivial thing for a person who has used indexReader to
> list all the fields in the index.
>
> On Wed, Mar 19, 2008 at 9:20 AM, Shai Erera <[EMAIL PROTECTED]> wrote:
> > Can you give an example of the output?
> > What does out.print() do? Does it print spaces between records on
> new-lines?
> >
> >
> > On Wed, Mar 19, 2008 at 3:17 PM, varun sood <[EMAIL PROTECTED]> wrote:
> >
> > > Hi All,
> > > Can someone please guide me on how to use IndexReader's
> > > getFieldNames() method properly?
> > > I want to get all the filed names in the index. Currently I am getitng
> > > it via Document object but that not wt i want.
> > > I am implementing the code below and what I get is a very long string
> > > of characters.. perhaps equivalent to the number of records in the
> > > index.
> > >
> > > Collection c = ir.getFieldNames(IndexReader.FieldOption.ALL);
> > > int i = 0;
> > > while (c.iterator().hasNext()) {
> > > Field s = (Field) c.iterator().next();
> > > out.print(s.name());
> > > i++;
> > > }
> > >
> > > Thanks,
> > > Varun.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> >
> > --
> > Regards,
> >
> > Shai Erera
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>