String wrap(String toWrap, int len, int start) {
    StringBuilder buff = new StringBuilder();
    StringBuilder line = new StringBuilder();

    char[] head = new char[start];
    Arrays.fill(head, ' ');

    for (StringTokenizer tok = new StringTokenizer(toWrap, " "); tok.hasMoreTokens();) {
      String next = tok.nextToken();
      if (line.length() + next.length() > len) {
        buff.append(line).append(separator).append(head);
        line.setLength(0);
      }

      line.append(line.length() == 0 ? "" : " ").append(next);
    }

    buff.append(line);
    return buff.toString();
  }
Wrap the specified string by breaking on space characters.

@param toWrap
         the string to wrap
@param len
         the maximum length of any line
@param start
         the number of spaces to pad at the
         beginning of a line
@return the wrapped string
beeline/src/java/org/apache/hive/beeline/BeeLine.java