0

I have the following...

DBCollection dbc = test.getCollection();
double count = dbc.count();
DBCursor cursor = dbc.find();
StringBuilder sb = new StringBuilder();
if( cursor.hasNext() )
  sb.append(cursor.next().toString());

This outputs only one record but shows a count of 2. This one seems to work...

DBCollection dbc = test.getCollection();
double count = dbc.count();
DBCursor cursor = dbc.find();
StringBuilder sb = new StringBuilder();
for(double i = 0.0; i<count; i++)
  sb.append(cursor.next().toString());

What am I missing

Jackie
  • 21,969
  • 32
  • 147
  • 289

1 Answers1

1

do you mean to use

while( cursor.hasNext() )
    sb.append(cursor.next().toString());

Right now, you use 'if' but you probably want 'while'.

Talandar
  • 116
  • 3