0

私は次のものを持っています...

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

これは 1 つのレコードのみを出力しますが、カウントは 2 です。これは機能しているようです...

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());

何が足りないの

4

1 に答える 1

1

使うということですか

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

今は「if」を使っていますが、おそらく「while」が必要でしょう。

于 2013-09-26T19:14:00.837 に答える