formatStringWithSpaces method

String formatStringWithSpaces()

Implementation

String formatStringWithSpaces() {
  StringBuffer buffer = StringBuffer();
  int length = this.length;

  for (int i = 0; i < length; i++) {
    if (i > 0 && i % 3 == 0) {
      buffer.write(' ');
    }
    buffer.write(this[i]);
  }

  return buffer.toString();
}