Use StringBuilder. Added a comment saying you most likely don't want to use wordWrap.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2330 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mjohnson
2008-06-25 21:27:01 +00:00
parent 7ad4e741ad
commit e8e1e766e4
+4 -1
View File
@@ -1299,13 +1299,16 @@ public class StringUtil
/**
* Wordwraps a string. Treats any whitespace character as a single character.
*
* <p>If you want the text to wrap for a graphical display, use a wordwrapping component
* such as {@link Label} instead.
*
* @param str String to word-wrap.
* @param width Maximum line length.
*/
public static String wordWrap (String str, int width)
{
int size = str.length();
StringBuffer buf = new StringBuffer(size + size/width);
StringBuilder buf = new StringBuilder(size + size/width);
int lastidx = 0;
while (lastidx < size) {
if (lastidx + width >= size) {