public static String insertLineBreaks(String message, int lineBreak,
    String lineBreakSymbol, String padString, boolean breakBeforeLineBreak) {
    
    StringBuilder sb = new StringBuilder();
    StringTokenizer st = new StringTokenizer(message != null ? message : "",
      " ");
    if (st.hasMoreElements()) {
      sb.append(st.nextElement().toString());
    }
    int length = sb.length();
    int pos;
    int count = 0;
    while (st.hasMoreElements()) {
      String tmp = st.nextElement().toString();
      
      if ((lineBreak < Integer.MAX_VALUE)
          && ((length >= lineBreak) || (breakBeforeLineBreak && (length + tmp
              .length()) >= lineBreak))) {
        sb.append(lineBreakSymbol);
        if (padString != null) {
          sb.append(padString);
        }
        count++;
        length = 0;
      } else {
        sb.append(' ');
      }
      
      // Append current element
      sb.append(tmp);
      
      // Change length
      if ((pos = tmp.indexOf(lineBreakSymbol)) >= 0) {
        length = tmp.length() - pos - lineBreakSymbol.length();
      } else {
        length += tmp.length() + 1;
      }
    }
    return sb.toString();
    
  }