do you mean to use
while( cursor.hasNext() )
sb.append(cursor.next().toString());
Right now, you use 'if' but you probably want 'while'.
题
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
解决方案
do you mean to use
while( cursor.hasNext() )
sb.append(cursor.next().toString());
Right now, you use 'if' but you probably want 'while'.