title: In MongoDB how to print document in the form of key=value pairs from a java client after getting all documents in a List?
body: <p>In MongoDB how to print document in the form of key=value pairs from a java client after getting all documents in a List?</p>
  
  <pre><code>public static void main(String[] args){
      MongoClient mongoClient = new MongoClient();
      MongoDatabase database = mongoClient.getDatabase("mydb");
      MongoCollection&lt;Document&gt; coll = database.getCollection("criminal");
      if (coll != null) {
      List&lt;Document&gt; foundDocument = coll.find().into(new ArrayList&lt;Document&gt;());
      Iterator&lt;Document&gt; itr = foundDocument.iterator();
      while (itr.hasNext()) {
  
      //System.out.println(itr.next());
      //here toString() method is overriden in Document so output is displaying
         }
       }
  </code></pre>