title: Java 8 - map to comma separated pairs in brackets
body: <p>What is the best way in <strong>Java 8</strong> to get from</p>
  
  <pre><code>Map&lt;Integer, Integer&gt;
  </code></pre>
  
  <p>to a String like:</p>
  
  <pre><code>[k1,v1],[k2,v2],[k3,v3]...
  </code></pre>
  
  <p>I am looking at something like this, but I don't know how to "return" or "map" the <code>StringBuilder</code>:</p>
  
  <pre><code>map.forEach( (k,v) -&gt; s.append("[").append(k).append(",").append(v).append("]") )
                      .collect(Collectors.joining(", "));
  </code></pre>
  
  <p>In any case, I believe <code>StringBuilder</code> is not suitable for multithreading in case of future paralelism.</p>
  
  <p>Note that I could iterate over the Map and create all the structure in an old fashion, but I would like to see how it could be done with some new Java8 features.</p>
  
  <p>I think some <code>toString()</code> by chance already returns the map values in brackets, which could be convenient, although it is not really a good idea to rely on this.</p>