fix for StringIndexOutOfBoundsException caused by overlong string passed to titleize(String str)

This commit is contained in:
Brettflan 2011-06-30 01:46:12 -05:00
parent 2f61e83a8a
commit 86112380da

View File

@ -12,7 +12,11 @@ public class TextUtil {
int pivot = line.length() / 2; int pivot = line.length() / 2;
int eatLeft = center.length() / 2; int eatLeft = center.length() / 2;
int eatRight = center.length() - eatLeft; int eatRight = center.length() - eatLeft;
if (eatLeft < pivot)
return line.substring(0, pivot - eatLeft) + center + line.substring(pivot + eatRight); return line.substring(0, pivot - eatLeft) + center + line.substring(pivot + eatRight);
else
return center;
} }
public static String repeat(String s, int times) { public static String repeat(String s, int times) {