title: Insert padding whitespace into string
body: <p>Pretty basic problem, but difficult to get into an acceptable form:</p>
  
  <p>I want to transform a string by inserting a padding every 3 whitespaces like</p>
  
  <p>"123456789" -> "123 456 789"</p>
  
  <p>"abcdefgh" -> "abc def gh"</p>
  
  <p>My code currently is</p>
  
  <pre><code>public String toSpaceSeparatedString(String s) {
    if (s == null || s.length() &lt; 3) {
      return s;
    }
  
    StringBuilder builder = new StringBuilder();
    int i; 
    for (i = 0; i &lt; s.length()-3; i += 3) {
      builder.append(s.substring(i, i+3));
      builder.append(" ");
    }
  
    builder.append(s.substring(i, s.length()));
  
    return builder.toString();
  }
  </code></pre>
  
  <p>Can anyone provide a more elegant solution?</p>