title: How to do this string pattern aaabbc to be displayed as 3a2b1c in java 8 using streams
body: <p>I want to display the String pattern <code>aaabbcc</code> to be displayed as <code>3a2b2c</code> in java8 using streams</p>
  <p>I have a working example in lower versions</p>
  <pre><code>String str = &quot;aabbcccddd&quot;;
  
  String chars[] = str.split(&quot;&quot;);
  Map&lt;String, Integer&gt; compressMap = new LinkedHashMap&lt;String, Integer&gt;();
  for(String s: chars) {
  if(&quot;&quot;.equals(s))
      continue;
  Integer count = compressMap.get(s);
  if(count != null)
      compressMap.put(s, ++count);
  else
      compressMap.put(s, 1);
  }
  
  StringBuffer output = new StringBuffer(&quot;&quot;);
  for (Map.Entry&lt;String, Integer&gt; entry : compressMap.entrySet()) {
      output.append(entry.getValue()).append(entry.getKey());
  }
  System.out.println(output);
  </code></pre>
  <p>can anyone help on this?</p>